summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/base_subprocess.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-07-31 15:49:43 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2015-07-31 15:49:43 (GMT)
commit6fb1e740c67d8940fe27883d77f0dc46431aa9b4 (patch)
tree9f165889ccdc7add17c4301b23c969e48fa740fc /Lib/asyncio/base_subprocess.py
parent062759f1dcfc025d1aae430ad89e22b8fd02dbf2 (diff)
downloadcpython-6fb1e740c67d8940fe27883d77f0dc46431aa9b4.zip
cpython-6fb1e740c67d8940fe27883d77f0dc46431aa9b4.tar.gz
cpython-6fb1e740c67d8940fe27883d77f0dc46431aa9b4.tar.bz2
Fix ResourceWarning in asyncio.BaseSubprocessTransport
Issue #24763: Fix resource warnings when asyncio.BaseSubprocessTransport constructor fails, if subprocess.Popen raises an exception for example. Patch written by Martin Richard, test written by me.
Diffstat (limited to 'Lib/asyncio/base_subprocess.py')
-rw-r--r--Lib/asyncio/base_subprocess.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/Lib/asyncio/base_subprocess.py b/Lib/asyncio/base_subprocess.py
index c1477b8..a6971b1 100644
--- a/Lib/asyncio/base_subprocess.py
+++ b/Lib/asyncio/base_subprocess.py
@@ -35,8 +35,13 @@ class BaseSubprocessTransport(transports.SubprocessTransport):
self._pipes[2] = None
# Create the child process: set the _proc attribute
- self._start(args=args, shell=shell, stdin=stdin, stdout=stdout,
- stderr=stderr, bufsize=bufsize, **kwargs)
+ try:
+ self._start(args=args, shell=shell, stdin=stdin, stdout=stdout,
+ stderr=stderr, bufsize=bufsize, **kwargs)
+ except:
+ self.close()
+ raise
+
self._pid = self._proc.pid
self._extra['subprocess'] = self._proc