gh-114177: avoid calling connection lost callbacks when loop is already closed in asyncio subprocess (GH-134508)
(cherry picked from commit
5804ee7b467d86131be3ff7d569443efb0d0f9fd)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
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?
--- /dev/null
+Fix :mod:`asyncio` to not close subprocess pipes which would otherwise error out when the event loop is already closed.