]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
asyncio: fix ResourceWarning related to subprocesses
authorVictor Stinner <victor.stinner@gmail.com>
Fri, 20 May 2016 11:05:48 +0000 (13:05 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Fri, 20 May 2016 11:05:48 +0000 (13:05 +0200)
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.

Lib/asyncio/base_subprocess.py

index 08080bd70124928fda4e13562d4f7c5bec61d9d8..8fc253c18eb981d1d6079ce374bfdafffed21261 100644 (file)
@@ -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()