]> granicus.if.org Git - python/commitdiff
asyncio: Close the transport on subprocess creation failure
authorVictor Stinner <victor.stinner@gmail.com>
Thu, 15 Jan 2015 13:24:22 +0000 (14:24 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Thu, 15 Jan 2015 13:24:22 +0000 (14:24 +0100)
Lib/asyncio/unix_events.py
Lib/asyncio/windows_events.py

index 9f4005cb13a690c77be775669f41af4f2c0b65d9..97f9addde88a0ada13eba3e26907918bbe2bcb69 100644 (file)
@@ -177,7 +177,11 @@ class _UnixSelectorEventLoop(selector_events.BaseSelectorEventLoop):
             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)
 
index 9d496f2f47ab67402618eb6f836aee542b3a667f..82d096637d5d38430c1b05b24e7dbcd3e5227574 100644 (file)
@@ -272,7 +272,12 @@ class ProactorEventLoop(proactor_events.BaseProactorEventLoop):
         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