]> granicus.if.org Git - python/commitdiff
subprocess: enhance ResourceWarning message
authorVictor Stinner <victor.stinner@gmail.com>
Tue, 14 Jun 2016 14:42:59 +0000 (16:42 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Tue, 14 Jun 2016 14:42:59 +0000 (16:42 +0200)
* Add the process identifier to the warning message
* Add also a comment to explain the issue

Lib/subprocess.py

index 98f339ee5c226f7fe9975a25424e6113a4387591..3dea089e6a751a85bb4ace04b39daee8ae9d0bb5 100644 (file)
@@ -993,7 +993,6 @@ class Popen(object):
 
             raise
 
-
     def _translate_newlines(self, data, encoding):
         data = data.decode(encoding)
         return data.replace("\r\n", "\n").replace("\r", "\n")
@@ -1018,8 +1017,10 @@ class Popen(object):
             # 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)
+            # Not reading subprocess exit status creates a zombi process which
+            # is only destroyed at the parent python process exit
+            warnings.warn("subprocess %s is still running" % self.pid,
+                          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: