subprocess now emits a ResourceWarning warning

Issue #26741: subprocess.Popen destructor now emits a ResourceWarning warning
if the child process is still running.
This commit is contained in:
Victor Stinner 2016-05-20 12:11:15 +02:00
parent a58e2c5c49
commit 5a48e21ff1
5 changed files with 26 additions and 2 deletions

View file

@ -1006,6 +1006,9 @@ class Popen(object):
if not self._child_created:
# We didn't get to successfully create a child process.
return
if self.returncode is None:
warnings.warn("running subprocess %r" % self, ResourceWarning,
source=self)
# In case the child hasn't been waited on, check if it's done.
self._internal_poll(_deadstate=_maxsize)
if self.returncode is None and _active is not None: