[Python-checkins] cpython (3.4): asyncio: Close the transport on subprocess creation failure

victor.stinner python-checkins at python.org
Thu Jan 15 14:26:29 CET 2015


https://hg.python.org/cpython/rev/6bace35f55e3
changeset:   94174:6bace35f55e3
branch:      3.4
parent:      94172:a35b790a2db3
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Thu Jan 15 14:24:22 2015 +0100
summary:
  asyncio: Close the transport on subprocess creation failure

files:
  Lib/asyncio/unix_events.py    |  6 +++++-
  Lib/asyncio/windows_events.py |  7 ++++++-
  2 files changed, 11 insertions(+), 2 deletions(-)


diff --git a/Lib/asyncio/unix_events.py b/Lib/asyncio/unix_events.py
--- a/Lib/asyncio/unix_events.py
+++ b/Lib/asyncio/unix_events.py
@@ -177,7 +177,11 @@
             transp = _UnixSubprocessTransport(self, protocol, args, shell,
                                               stdin, stdout, stderr, bufsize,
                                               extra=extra, **kwargs)
-            yield from transp._post_init()
+            try:
+                yield from transp._post_init()
+            except:
+                transp.close()
+                raise
             watcher.add_child_handler(transp.get_pid(),
                                       self._child_watcher_callback, transp)
 
diff --git a/Lib/asyncio/windows_events.py b/Lib/asyncio/windows_events.py
--- a/Lib/asyncio/windows_events.py
+++ b/Lib/asyncio/windows_events.py
@@ -272,7 +272,12 @@
         transp = _WindowsSubprocessTransport(self, protocol, args, shell,
                                              stdin, stdout, stderr, bufsize,
                                              extra=extra, **kwargs)
-        yield from transp._post_init()
+        try:
+            yield from transp._post_init()
+        except:
+            transp.close()
+            raise
+
         return transp
 
 

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list