Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3bcc017

Browse files
author
Victor Stinner
committed
(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.
2 parents ac6602b + 0f83b15 commit 3bcc017

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

Lib/multiprocessing/process.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,15 @@ def _bootstrap(self):
267267
sys.stdin = open(os.devnull)
268268
except (OSError, ValueError):
269269
pass
270+
old_process = _current_process
270271
_current_process = self
271-
util._finalizer_registry.clear()
272-
util._run_after_forkers()
272+
try:
273+
util._finalizer_registry.clear()
274+
util._run_after_forkers()
275+
finally:
276+
# delay finalization of the old process object until after
277+
# _run_after_forkers() is executed
278+
del old_process
273279
util.info('child process calling self.run()')
274280
try:
275281
self.run()

0 commit comments

Comments
 (0)