Skip to content

Commit

Permalink
Merge pull request Yelp#12 from jnb/pre-fork-init
Browse files Browse the repository at this point in the history
Invoke pre-fork initialization function.
  • Loading branch information
eklitzke committed Oct 13, 2011
2 parents 42a0948 + 24ce5ea commit 6986f82
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion zygote/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def __init__(self, sock, basepath, module, args):

os.chdir(basepath)
sys.path.insert(0, basepath)
t = __import__(module, [], [], ['get_application'], 0)
t = __import__(module, [], [], ['initialize', 'get_application'], 0)

self.sock = sock

Expand All @@ -86,6 +86,11 @@ def __init__(self, sock, basepath, module, args):

signal.signal(signal.SIGCHLD, self.reap_child)

# If there is an initialize function defined then call it.
if hasattr(t, 'initialize'):
self.log.info('initializing zygote')
t.initialize(*self.args)

self.log.info('new zygote started')

def handle_control(self, fd, events):
Expand Down

0 comments on commit 6986f82

Please sign in to comment.