diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-01-15 14:18:33 +0100 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-01-15 14:18:33 +0100 |
commit | 180ea50b9a83de00713f8a4ecd1a91ed080968ac (patch) | |
tree | a388bc69486dc96d4f91e4d6b5b208b5e7b2167d | |
parent | 7179b0d65269b1accb1de6455cb0662b38b0448f (diff) | |
download | trollius-180ea50b9a83de00713f8a4ecd1a91ed080968ac.tar.gz |
Close the transport on subprocess creation failure
-rw-r--r-- | asyncio/unix_events.py | 6 | ||||
-rw-r--r-- | asyncio/windows_events.py | 7 |
2 files changed, 11 insertions, 2 deletions
diff --git a/asyncio/unix_events.py b/asyncio/unix_events.py index 9f4005c..97f9add 100644 --- a/asyncio/unix_events.py +++ b/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/asyncio/windows_events.py b/asyncio/windows_events.py index 9d496f2..82d0966 100644 --- a/asyncio/windows_events.py +++ b/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 |