asyncio: Close the transport on subprocess creation failure

This commit is contained in:
Victor Stinner 2015-01-15 14:24:22 +01:00
parent fcd58de78f
commit 4bf22e033e
2 changed files with 11 additions and 2 deletions

View file

@ -177,7 +177,11 @@ class _UnixSelectorEventLoop(selector_events.BaseSelectorEventLoop):
transp = _UnixSubprocessTransport(self, protocol, args, shell, transp = _UnixSubprocessTransport(self, protocol, args, shell,
stdin, stdout, stderr, bufsize, stdin, stdout, stderr, bufsize,
extra=extra, **kwargs) 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(), watcher.add_child_handler(transp.get_pid(),
self._child_watcher_callback, transp) self._child_watcher_callback, transp)

View file

@ -272,7 +272,12 @@ class ProactorEventLoop(proactor_events.BaseProactorEventLoop):
transp = _WindowsSubprocessTransport(self, protocol, args, shell, transp = _WindowsSubprocessTransport(self, protocol, args, shell,
stdin, stdout, stderr, bufsize, stdin, stdout, stderr, bufsize,
extra=extra, **kwargs) extra=extra, **kwargs)
yield from transp._post_init() try:
yield from transp._post_init()
except:
transp.close()
raise
return transp return transp