diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2016-05-20 11:05:48 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2016-05-20 11:05:48 (GMT) |
commit | b0d43ce890adbcfea2e1dff7ba6e76c5c046b61c (patch) | |
tree | 89dbd5c5e651199e281ff2b817656d928eec209e | |
parent | 387e6e38175b853741c4f35e08791f0990bc0845 (diff) | |
download | cpython-b0d43ce890adbcfea2e1dff7ba6e76c5c046b61c.zip cpython-b0d43ce890adbcfea2e1dff7ba6e76c5c046b61c.tar.gz cpython-b0d43ce890adbcfea2e1dff7ba6e76c5c046b61c.tar.bz2 |
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.
-rw-r--r-- | Lib/asyncio/base_subprocess.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/asyncio/base_subprocess.py b/Lib/asyncio/base_subprocess.py index 08080bd..8fc253c 100644 --- a/Lib/asyncio/base_subprocess.py +++ b/Lib/asyncio/base_subprocess.py @@ -210,6 +210,10 @@ class BaseSubprocessTransport(transports.SubprocessTransport): logger.info('%r exited with return code %r', self, 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._try_finish() |