mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
gh-90549: Fix leak of global named resources using multiprocessing spawn (#30617)
Co-authored-by: XD Trol <milestonejxd@gmail.com> Co-authored-by: Antoine Pitrou <pitrou@free.fr>
This commit is contained in:
parent
6099611af5
commit
30610d2837
4 changed files with 54 additions and 2 deletions
|
@ -223,6 +223,10 @@ class Process(process.BaseProcess):
|
|||
def _Popen(process_obj):
|
||||
return _default_context.get_context().Process._Popen(process_obj)
|
||||
|
||||
@staticmethod
|
||||
def _after_fork():
|
||||
return _default_context.get_context().Process._after_fork()
|
||||
|
||||
class DefaultContext(BaseContext):
|
||||
Process = Process
|
||||
|
||||
|
@ -283,6 +287,11 @@ if sys.platform != 'win32':
|
|||
from .popen_spawn_posix import Popen
|
||||
return Popen(process_obj)
|
||||
|
||||
@staticmethod
|
||||
def _after_fork():
|
||||
# process is spawned, nothing to do
|
||||
pass
|
||||
|
||||
class ForkServerProcess(process.BaseProcess):
|
||||
_start_method = 'forkserver'
|
||||
@staticmethod
|
||||
|
@ -326,6 +335,11 @@ else:
|
|||
from .popen_spawn_win32 import Popen
|
||||
return Popen(process_obj)
|
||||
|
||||
@staticmethod
|
||||
def _after_fork():
|
||||
# process is spawned, nothing to do
|
||||
pass
|
||||
|
||||
class SpawnContext(BaseContext):
|
||||
_name = 'spawn'
|
||||
Process = SpawnProcess
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue