[Python-checkins] cpython (merge 3.2 -> default): (Merge 3.2) Issue #12310: finalize the old process after _run_after_forkers()

victor.stinner python-checkins at python.org
Fri Jun 17 12:38:34 CEST 2011


http://hg.python.org/cpython/rev/a73e5c1f57d7
changeset:   70832:a73e5c1f57d7
parent:      70830:276530424350
parent:      70831:e6e7e42efdc2
user:        Victor Stinner <victor.stinner at haypocalc.com>
date:        Fri Jun 17 12:36:26 2011 +0200
summary:
  (Merge 3.2) Issue #12310: finalize the old process after _run_after_forkers()

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.

files:
  Lib/multiprocessing/process.py |  10 ++++++++--
  1 files changed, 8 insertions(+), 2 deletions(-)


diff --git a/Lib/multiprocessing/process.py b/Lib/multiprocessing/process.py
--- a/Lib/multiprocessing/process.py
+++ b/Lib/multiprocessing/process.py
@@ -267,9 +267,15 @@
                     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()

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list