diff options
author | Victor Stinner <vstinner@redhat.com> | 2018-06-27 13:18:39 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-27 13:18:39 (GMT) |
commit | 0aab8660cdaa540730994afbce49a146dd779bce (patch) | |
tree | 239202f2522f1020e7c5f29d1675b2b11becb06c /Lib | |
parent | 2cc9d21fffb8146d30e6fb4221e32410ba4b4ab7 (diff) | |
download | cpython-0aab8660cdaa540730994afbce49a146dd779bce.zip cpython-0aab8660cdaa540730994afbce49a146dd779bce.tar.gz cpython-0aab8660cdaa540730994afbce49a146dd779bce.tar.bz2 |
bpo-33929: Fix regression in spawn_main() (#7962)
OpenProcess() creates a new handle that must be closed later.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/multiprocessing/spawn.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/multiprocessing/spawn.py b/Lib/multiprocessing/spawn.py index 2de4cb7..73aa694 100644 --- a/Lib/multiprocessing/spawn.py +++ b/Lib/multiprocessing/spawn.py @@ -103,8 +103,12 @@ def spawn_main(pipe_handle, parent_pid=None, tracker_fd=None): _winapi.PROCESS_DUP_HANDLE, False, parent_pid) else: source_process = None - new_handle = reduction.duplicate(pipe_handle, - source_process=source_process) + try: + new_handle = reduction.duplicate(pipe_handle, + source_process=source_process) + finally: + if source_process is not None: + _winapi.CloseHandle(source_process) fd = msvcrt.open_osfhandle(new_handle, os.O_RDONLY) else: from . import semaphore_tracker |