subprocess now emits a ResourceWarning warning
Issue #26741: subprocess.Popen destructor now emits a ResourceWarning warning
if the child process is still running.
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index 41a9de1..b853f4d 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -1006,6 +1006,9 @@
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: