]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #12310: finalize the old process after _run_after_forkers()
authorVictor Stinner <victor.stinner@haypocalc.com>
Fri, 17 Jun 2011 10:31:49 +0000 (12:31 +0200)
committerVictor Stinner <victor.stinner@haypocalc.com>
Fri, 17 Jun 2011 10:31:49 +0000 (12:31 +0200)
multiprocessing: Process._bootstrap() keeps a reference to the old process to
delay its finalization until after _run_after_forkers() as been executed. This
change should fix a crash on Mac OS X Tiger when a lock is released after a
fork.

Patch written by Charles-François Nataliv and Antoine Pitrou.

Lib/multiprocessing/process.py

index b56a061079a1a16040297c878bf04bb72709d40f..941893fcc60efd8e476c9828450767e84a4b1cd9 100644 (file)
@@ -251,9 +251,15 @@ class Process(object):
                     sys.stdin = open(os.devnull)
                 except (OSError, ValueError):
                     pass
+            old_process = _current_process
             _current_process = self
-            util._finalizer_registry.clear()
-            util._run_after_forkers()
+            try:
+                util._finalizer_registry.clear()
+                util._run_after_forkers()
+            finally:
+                # delay finalization of the old process object until after
+                # _run_after_forkers() is executed
+                del old_process
             util.info('child process calling self.run()')
             try:
                 self.run()