Permalink
Browse files

fork: public on_fork() function.

Generally useful, and needed for ongoing Ansible work.
  • Loading branch information...
dw committed Jul 30, 2018
1 parent 3e0de97 commit af2ded663da2fcbc4ce813f7aafbb64fc7906f9c
Showing with 12 additions and 4 deletions.
  1. +12 −4 mitogen/fork.py
@@ -75,6 +75,17 @@ def reset_logging_framework():
]


def on_fork():
"""
Should be called by any program integrating Mitogen each time the process
is forked, in the context of the new child.
"""
reset_logging_framework() # Must be first!
fixup_prngs()
mitogen.core.Latch._on_fork()
mitogen.core.Side._on_fork()


def handle_child_crash():
"""
Respond to _child_main() crashing by ensuring the relevant exception is
@@ -134,10 +145,7 @@ def _wrap_child_main(self, childfp):
handle_child_crash()

def _child_main(self, childfp):
reset_logging_framework() # Must be first!
fixup_prngs()
mitogen.core.Latch._on_fork()
mitogen.core.Side._on_fork()
on_fork()
if self.on_fork:
self.on_fork()
mitogen.core.set_block(childfp.fileno())

0 comments on commit af2ded6

Please sign in to comment.