From: Victor Stinner Date: Thu, 15 Jan 2015 13:24:22 +0000 (+0100) Subject: asyncio: Close the transport on subprocess creation failure X-Git-Tag: v3.4.3rc1~124 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4bf22e033e975f61c33752db5a3764dc0f7d0b03;p=python asyncio: Close the transport on subprocess creation failure --- diff --git a/Lib/asyncio/unix_events.py b/Lib/asyncio/unix_events.py index 9f4005cb13..97f9addde8 100644 --- a/Lib/asyncio/unix_events.py +++ b/Lib/asyncio/unix_events.py @@ -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) diff --git a/Lib/asyncio/windows_events.py b/Lib/asyncio/windows_events.py index 9d496f2f47..82d096637d 100644 --- a/Lib/asyncio/windows_events.py +++ b/Lib/asyncio/windows_events.py @@ -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