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

@ -2286,7 +2286,9 @@ class POSIXProcessTestCase(BaseTestCase):
self.addCleanup(p.stderr.close)
ident = id(p)
pid = p.pid
del p
with support.check_warnings(('', ResourceWarning)):
p = None
# check that p is in the active processes list
self.assertIn(ident, [id(o) for o in subprocess._active])
@ -2305,7 +2307,9 @@ class POSIXProcessTestCase(BaseTestCase):
self.addCleanup(p.stderr.close)
ident = id(p)
pid = p.pid
del p
with support.check_warnings(('', ResourceWarning)):
p = None
os.kill(pid, signal.SIGKILL)
# check that p is in the active processes list
self.assertIn(ident, [id(o) for o in subprocess._active])