diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2016-06-14 14:42:59 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2016-06-14 14:42:59 (GMT) |
commit | c206f1eb1c4d5ac397ce7059e56bb201e44a0ce9 (patch) | |
tree | 4c3edcad0fda4523678f541b6340f330b1c613a4 /Lib/subprocess.py | |
parent | d017176209d8317be1548e3775019149526324cb (diff) | |
download | cpython-c206f1eb1c4d5ac397ce7059e56bb201e44a0ce9.zip cpython-c206f1eb1c4d5ac397ce7059e56bb201e44a0ce9.tar.gz cpython-c206f1eb1c4d5ac397ce7059e56bb201e44a0ce9.tar.bz2 |
subprocess: enhance ResourceWarning message
* Add the process identifier to the warning message
* Add also a comment to explain the issue
Diffstat (limited to 'Lib/subprocess.py')
-rw-r--r-- | Lib/subprocess.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Lib/subprocess.py b/Lib/subprocess.py index 98f339e..3dea089 100644 --- a/Lib/subprocess.py +++ b/Lib/subprocess.py @@ -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: |