Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
fork: public on_fork() function.
Generally useful, and needed for ongoing Ansible work.
- Loading branch information
Showing
with
12 additions
and
4 deletions.
-
+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()) |
|
|