Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Lib/asyncio/base_subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,12 @@ def close(self):
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?
Expand Down
12 changes: 9 additions & 3 deletions Lib/asyncio/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,17 @@ class NodeType(Enum):
TASK = 2


@dataclass(frozen=True)
class CycleFoundException(Exception):
"""Raised when there is a cycle when drawing the call tree."""
cycles: list[list[int]]
id2name: dict[int, str]
def __init__(
self,
cycles: list[list[int]],
id2name: dict[int, str],
) -> None:
super().__init__(cycles, id2name)
self.cycles = cycles
self.id2name = id2name



# ─── indexing helpers ───────────────────────────────────────────
Expand Down
2 changes: 0 additions & 2 deletions Lib/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ def deleter(self, fdel):


class _GeneratorWrapper:
# TODO: Implement this in C.
def __init__(self, gen):
self.__wrapped = gen
self.__isgen = gen.__class__ is GeneratorType
Expand Down Expand Up @@ -305,7 +304,6 @@ def coroutine(func):
# Check if 'func' is a generator function.
# (0x20 == CO_GENERATOR)
if co_flags & 0x20:
# TODO: Implement this in C.
co = func.__code__
# 0x100 == CO_ITERABLE_COROUTINE
func.__code__ = co.replace(co_flags=co.co_flags | 0x100)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix :mod:`asyncio` to not close subprocess pipes which would otherwise error out when the event loop is already closed.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Converted ``asyncio.tools.CycleFoundException`` from dataclass to a regular exception type.
Loading