X Tutup
Skip to content

Commit 0f83b15

Browse files
author
Victor Stinner
committed
Issue python#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.
1 parent b4cfa3a commit 0f83b15

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Lib/multiprocessing/process.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,15 @@ def _bootstrap(self):
251251
sys.stdin = open(os.devnull)
252252
except (OSError, ValueError):
253253
pass
254+
old_process = _current_process
254255
_current_process = self
255-
util._finalizer_registry.clear()
256-
util._run_after_forkers()
256+
try:
257+
util._finalizer_registry.clear()
258+
util._run_after_forkers()
259+
finally:
260+
# delay finalization of the old process object until after
261+
# _run_after_forkers() is executed
262+
del old_process
257263
util.info('child process calling self.run()')
258264
try:
259265
self.run()

0 commit comments

Comments
 (0)
X Tutup