Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b0d43ce

Browse files
committed
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.
1 parent 387e6e3 commit b0d43ce

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

Lib/asyncio/base_subprocess.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,10 @@ def _process_exited(self, returncode):
210210
logger.info('%r exited with return code %r',
211211
self, returncode)
212212
self._returncode = returncode
213+
if self._proc.returncode is None:
214+
# asyncio uses a child watcher: copy the status into the Popen
215+
# object. On Python 3.6, it is required to avoid a ResourceWarning.
216+
self._proc.returncode = returncode
213217
self._call(self._protocol.process_exited)
214218
self._try_finish()
215219

0 commit comments

Comments
 (0)