[issue37410] [Windows] subprocess: close the handle when the process completes

2019-06-26 Thread STINNER Victor
STINNER Victor added the comment: terminate() was changed by: commit a0c9caad66f01328155177180df1c46fe7c62e57 Author: Gregory P. Smith Date: Sun Nov 15 18:19:10 2015 -0800 Fix issue #6973: When we know a subprocess.Popen process has died, do not allow the send_signal(), terminate()

[issue37410] [Windows] subprocess: close the handle when the process completes

2019-06-26 Thread STINNER Victor
STINNER Victor added the comment: We may backport the change to Python 2.7 as well, but in this case terminate() must be changed to test returncode: def terminate(self): """Terminates the process.""" # Don't terminate a process that we know has already died.

[issue37410] [Windows] subprocess: close the handle when the process completes

2019-06-26 Thread STINNER Victor
STINNER Victor added the comment: See also bpo-37380: subprocess.Popen._cleanup() "The handle is invalid" error when some old process is gone. -- ___ Python tracker ___ _

[issue37410] [Windows] subprocess: close the handle when the process completes

2019-06-26 Thread STINNER Victor
STINNER Victor added the comment: IMHO it's safe to backport PR 14391 to Python 3.7 and 3.8. -- versions: +Python 3.7, Python 3.8 ___ Python tracker ___ __

[issue37410] [Windows] subprocess: close the handle when the process completes

2019-06-26 Thread STINNER Victor
Change by STINNER Victor : -- keywords: +patch pull_requests: +14205 stage: -> patch review pull_request: https://github.com/python/cpython/pull/14391 ___ Python tracker ___ _

[issue37410] [Windows] subprocess: close the handle when the process completes

2019-06-26 Thread STINNER Victor
New submission from STINNER Victor : subprocess.Popen uses _winapi.CreateProcess() to spawn a child process. It stores the process handle using a Handle class. Popen never explicitly releases the handle, it rely on Handle.__del__ when the Popen object is detroyed (when Popen._handle attribute