mirror of
https://github.com/python/cpython.git
synced 2025-09-19 15:10:58 +00:00
asyncio: fix ResourceWarning related to subprocesses
Issue #26741: asyncio: BaseSubprocessTransport._process_exited() now copies the return code from the child watched to the returncode attribute of the Popen object. On Python 3.6, it is required to avoid a ResourceWarning.
This commit is contained in:
parent
387e6e3817
commit
b0d43ce890
1 changed files with 4 additions and 0 deletions
|
@ -210,6 +210,10 @@ class BaseSubprocessTransport(transports.SubprocessTransport):
|
||||||
logger.info('%r exited with return code %r',
|
logger.info('%r exited with return code %r',
|
||||||
self, returncode)
|
self, returncode)
|
||||||
self._returncode = returncode
|
self._returncode = returncode
|
||||||
|
if self._proc.returncode is None:
|
||||||
|
# asyncio uses a child watcher: copy the status into the Popen
|
||||||
|
# object. On Python 3.6, it is required to avoid a ResourceWarning.
|
||||||
|
self._proc.returncode = returncode
|
||||||
self._call(self._protocol.process_exited)
|
self._call(self._protocol.process_exited)
|
||||||
self._try_finish()
|
self._try_finish()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue