summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio
diff options
context:
space:
mode:
authorKumar Aditya <59607654+kumaraditya303@users.noreply.github.com>2022-10-05 17:15:31 (GMT)
committerGitHub <noreply@github.com>2022-10-05 17:15:31 (GMT)
commit7015e1379791cbf19908cd1a7c668a5d6e7165d5 (patch)
tree1bd888e4ba361d3fab3dc95d5b550bdc22a76c04 /Lib/asyncio
parent0e72606dd4cf3023a4f8c2fe3c58082592b253f7 (diff)
downloadcpython-7015e1379791cbf19908cd1a7c668a5d6e7165d5.zip
cpython-7015e1379791cbf19908cd1a7c668a5d6e7165d5.tar.gz
cpython-7015e1379791cbf19908cd1a7c668a5d6e7165d5.tar.bz2
gh-88050: Fix asyncio subprocess to kill process cleanly when process is blocked (#32073)
Diffstat (limited to 'Lib/asyncio')
-rw-r--r--Lib/asyncio/base_subprocess.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/Lib/asyncio/base_subprocess.py b/Lib/asyncio/base_subprocess.py
index 14d5051..c2ca4a2 100644
--- a/Lib/asyncio/base_subprocess.py
+++ b/Lib/asyncio/base_subprocess.py
@@ -215,14 +215,10 @@ class BaseSubprocessTransport(transports.SubprocessTransport):
# object. On Python 3.6, it is required to avoid a ResourceWarning.
self._proc.returncode = returncode
self._call(self._protocol.process_exited)
+ for p in self._pipes.values():
+ p.pipe.close()
self._try_finish()
- # wake up futures waiting for wait()
- for waiter in self._exit_waiters:
- if not waiter.cancelled():
- waiter.set_result(returncode)
- self._exit_waiters = None
-
async def _wait(self):
"""Wait until the process exit and return the process return code.
@@ -247,6 +243,11 @@ class BaseSubprocessTransport(transports.SubprocessTransport):
try:
self._protocol.connection_lost(exc)
finally:
+ # wake up futures waiting for wait()
+ for waiter in self._exit_waiters:
+ if not waiter.cancelled():
+ waiter.set_result(self._returncode)
+ self._exit_waiters = None
self._loop = None
self._proc = None
self._protocol = None