[Python-checkins] bpo-33929: Fix regression in spawn_main() (#7962)

Victor Stinner webhook-mailer at python.org
Wed Jun 27 09:18:42 EDT 2018


https://github.com/python/cpython/commit/0aab8660cdaa540730994afbce49a146dd779bce
commit: 0aab8660cdaa540730994afbce49a146dd779bce
branch: master
author: Victor Stinner <vstinner at redhat.com>
committer: GitHub <noreply at github.com>
date: 2018-06-27T15:18:39+02:00
summary:

bpo-33929: Fix regression in spawn_main() (#7962)

OpenProcess() creates a new handle that must be closed later.

files:
M Lib/multiprocessing/spawn.py

diff --git a/Lib/multiprocessing/spawn.py b/Lib/multiprocessing/spawn.py
index 2de4cb7f6378..73aa69471f29 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



More information about the Python-checkins mailing list