mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
asyncio: Close the transport on subprocess creation failure
This commit is contained in:
parent
fcd58de78f
commit
4bf22e033e
2 changed files with 11 additions and 2 deletions
|
@ -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)
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue