mirror of
https://github.com/python/cpython.git
synced 2025-07-23 11:15:24 +00:00
Fix ResourceWarning in asyncio.BaseSubprocessTransport
Issue #24763: Fix resource warnings when asyncio.BaseSubprocessTransport constructor fails, if subprocess.Popen raises an exception for example. Patch written by Martin Richard, test written by me.
This commit is contained in:
parent
062759f1dc
commit
6fb1e740c6
2 changed files with 22 additions and 2 deletions
|
@ -35,8 +35,13 @@ class BaseSubprocessTransport(transports.SubprocessTransport):
|
|||
self._pipes[2] = None
|
||||
|
||||
# Create the child process: set the _proc attribute
|
||||
self._start(args=args, shell=shell, stdin=stdin, stdout=stdout,
|
||||
stderr=stderr, bufsize=bufsize, **kwargs)
|
||||
try:
|
||||
self._start(args=args, shell=shell, stdin=stdin, stdout=stdout,
|
||||
stderr=stderr, bufsize=bufsize, **kwargs)
|
||||
except:
|
||||
self.close()
|
||||
raise
|
||||
|
||||
self._pid = self._proc.pid
|
||||
self._extra['subprocess'] = self._proc
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue