mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
gh-90549: Fix leak of global named resources using multiprocessing spawn (GH-30617)
Co-authored-by: XD Trol <milestonejxd@gmail.com>
Co-authored-by: Antoine Pitrou <pitrou@free.fr>
(cherry picked from commit 30610d2837
)
Co-authored-by: Leo Trol <milestone.jxd@gmail.com>
This commit is contained in:
parent
62cae22c0d
commit
aee7d3df1c
4 changed files with 54 additions and 2 deletions
|
@ -304,8 +304,7 @@ class BaseProcess(object):
|
|||
if threading._HAVE_THREAD_NATIVE_ID:
|
||||
threading.main_thread()._set_native_id()
|
||||
try:
|
||||
util._finalizer_registry.clear()
|
||||
util._run_after_forkers()
|
||||
self._after_fork()
|
||||
finally:
|
||||
# delay finalization of the old process object until after
|
||||
# _run_after_forkers() is executed
|
||||
|
@ -336,6 +335,13 @@ class BaseProcess(object):
|
|||
|
||||
return exitcode
|
||||
|
||||
@staticmethod
|
||||
def _after_fork():
|
||||
from . import util
|
||||
util._finalizer_registry.clear()
|
||||
util._run_after_forkers()
|
||||
|
||||
|
||||
#
|
||||
# We subclass bytes to avoid accidental transmission of auth keys over network
|
||||
#
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue