Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(25355)

Unified Diff: Lib/subprocess.py

Issue 26741: subprocess.Popen should emit a ResourceWarning in destructor if the process is still running
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Lib/test/test_subprocess.py » ('j') | Lib/test/test_subprocess.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/subprocess.py Tue Apr 12 22:38:22 2016 +0200
+++ b/Lib/subprocess.py Wed Apr 13 00:41:49 2016 +0200
@@ -1005,6 +1005,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:
@@ -1519,10 +1522,14 @@ class Popen(object):
os.close(errpipe_read)
if errpipe_data:
+ self.returncode = 255
try:
- os.waitpid(self.pid, 0)
+ pid, sts = os.waitpid(self.pid, 0)
+ if pid == self.pid:
Martin Panter 2016/04/13 04:31:30 Is it possible for this to not be the case, i.e. w
+ self._handle_exitstatus(sts)
except ChildProcessError:
pass
+
try:
exception_name, hex_errno, err_msg = (
errpipe_data.split(b':', 2))
« no previous file with comments | « no previous file | Lib/test/test_subprocess.py » ('j') | Lib/test/test_subprocess.py » ('J')

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+