From 0f83b1511c76e892b48b16d656cceb032bdb9cb3 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 17 Jun 2011 12:31:49 +0200 Subject: Issue #12310: finalize the old process after _run_after_forkers() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Lib/multiprocessing/process.py b/Lib/multiprocessing/process.py index b56a061..941893f 100644 --- a/Lib/multiprocessing/process.py +++ b/Lib/multiprocessing/process.py @@ -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() -- cgit v0.12