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

STINNER Victor report at bugs.python.org
Wed Jun 26 07:53:14 EDT 2019


New submission from STINNER Victor <vstinner at redhat.com>:

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 is cleared).

As discussed in bpo-37380, we could call explicitly CloseHandle(handle) as soon as the child process completes, to release resources in the Windows kernel.

Attached PR implements this fix.

----------
components: Library (Lib)
messages: 346603
nosy: vstinner
priority: normal
severity: normal
status: open
title: [Windows] subprocess: close the handle when the process completes
type: resource usage
versions: Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37410>
_______________________________________


More information about the Python-bugs-list mailing list