diff options
| author | Leo Trol <milestone.jxd@gmail.com> | 2022-06-09 16:55:12 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-09 16:55:12 (GMT) |
| commit | 30610d28374f5a9698d456cebf3ae496ac01af51 (patch) | |
| tree | 92599812169f8f0239cc9010c8e2e4ab2ded98f1 /Lib/multiprocessing/context.py | |
| parent | 6099611af5b9688f015ae4796501ce101a1c2f32 (diff) | |
| download | cpython-30610d28374f5a9698d456cebf3ae496ac01af51.zip cpython-30610d28374f5a9698d456cebf3ae496ac01af51.tar.gz cpython-30610d28374f5a9698d456cebf3ae496ac01af51.tar.bz2 | |
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>
Diffstat (limited to 'Lib/multiprocessing/context.py')
| -rw-r--r-- | Lib/multiprocessing/context.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/multiprocessing/context.py b/Lib/multiprocessing/context.py index 8d0525d..b1960ea 100644 --- a/Lib/multiprocessing/context.py +++ b/Lib/multiprocessing/context.py @@ -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 |
