Skip to content

Commit 5987ebc

Browse files
[3.13] gh-114177: avoid calling connection lost callbacks when loop is already closed in asyncio subprocess (GH-134508) (#134562)
gh-114177: avoid calling connection lost callbacks when loop is already closed in asyncio subprocess (GH-134508) (cherry picked from commit 5804ee7) Co-authored-by: Kumar Aditya <[email protected]>
1 parent 1a61d81 commit 5987ebc

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Lib/asyncio/base_subprocess.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,12 @@ def close(self):
104104
for proto in self._pipes.values():
105105
if proto is None:
106106
continue
107-
proto.pipe.close()
107+
# See gh-114177
108+
# skip closing the pipe if loop is already closed
109+
# this can happen e.g. when loop is closed immediately after
110+
# process is killed
111+
if self._loop and not self._loop.is_closed():
112+
proto.pipe.close()
108113

109114
if (self._proc is not None and
110115
# has the child process finished?
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix :mod:`asyncio` to not close subprocess pipes which would otherwise error out when the event loop is already closed.

0 commit comments

Comments
 (0)