]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-114177: avoid calling connection lost callbacks when loop is already closed in...
authorKumar Aditya <kumaraditya@python.org>
Fri, 23 May 2025 04:33:16 +0000 (10:03 +0530)
committerGitHub <noreply@github.com>
Fri, 23 May 2025 04:33:16 +0000 (10:03 +0530)
Lib/asyncio/base_subprocess.py
Misc/NEWS.d/next/Library/2025-05-22-13-10-32.gh-issue-114177.3TYUJ3.rst [new file with mode: 0644]

index 9c2ba679ce2bf1debf340062b8b0f23c4d373add..d40af422e614c1551feff6697206e9f82236d22f 100644 (file)
@@ -104,7 +104,12 @@ class BaseSubprocessTransport(transports.SubprocessTransport):
         for proto in self._pipes.values():
             if proto is None:
                 continue
-            proto.pipe.close()
+            # See gh-114177
+            # skip closing the pipe if loop is already closed
+            # this can happen e.g. when loop is closed immediately after
+            # process is killed
+            if self._loop and not self._loop.is_closed():
+                proto.pipe.close()
 
         if (self._proc is not None and
                 # has the child process finished?
diff --git a/Misc/NEWS.d/next/Library/2025-05-22-13-10-32.gh-issue-114177.3TYUJ3.rst b/Misc/NEWS.d/next/Library/2025-05-22-13-10-32.gh-issue-114177.3TYUJ3.rst
new file mode 100644 (file)
index 0000000..c98fde5
--- /dev/null
@@ -0,0 +1 @@
+Fix :mod:`asyncio` to not close subprocess pipes which would otherwise error out when the event loop is already closed.