aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/asyncio/tools.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/asyncio/tools.py')
-rw-r--r--Lib/asyncio/tools.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/Lib/asyncio/tools.py b/Lib/asyncio/tools.py
index bf1cb5e64cb..3fc4524c008 100644
--- a/Lib/asyncio/tools.py
+++ b/Lib/asyncio/tools.py
@@ -1,11 +1,10 @@
"""Tools to analyze tasks running in asyncio programs."""
-from dataclasses import dataclass
from collections import defaultdict
from itertools import count
from enum import Enum
import sys
-from _remote_debugging import get_all_awaited_by
+from _remote_debugging import RemoteUnwinder
class NodeType(Enum):
@@ -13,11 +12,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 ───────────────────────────────────────────
@@ -112,6 +117,11 @@ def _find_cycles(graph):
# ─── PRINT TREE FUNCTION ───────────────────────────────────────
+def get_all_awaited_by(pid):
+ unwinder = RemoteUnwinder(pid)
+ return unwinder.get_all_awaited_by()
+
+
def build_async_tree(result, task_emoji="(T)", cor_emoji=""):
"""
Build a list of strings for pretty-print an async call tree.