Skip to content

Commit fc083ad

Browse files
authored
gh-161173: Fix outdated docs for get_async_stack_trace (#161174)
1 parent bb9d26d commit fc083ad

2 files changed

Lines changed: 102 additions & 47 deletions

File tree

‎Modules/_remote_debugging/clinic/module.c.h‎

Lines changed: 51 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Modules/_remote_debugging/module.c‎

Lines changed: 51 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,44 +1010,70 @@ For each thread with a running task, returns the running task plus
10101010
all tasks that transitively depend on it (tasks waiting for the
10111011
running task, tasks waiting for those tasks, etc.).
10121012
1013-
Returns a list of per-thread results, where each thread result
1014-
contains:
1015-
- Thread ID
1016-
- List of task information for the running task and all its waiters
1013+
Returns:
1014+
A list of AwaitedInfo objects, where each object contains:
10171015
1018-
Each task info contains:
1019-
- Task ID (memory address)
1020-
- Task name
1021-
- Call stack frames: List of (func_name, filename, lineno)
1022-
- List of tasks waiting for this task (recursive structure)
1016+
- thread_id (int): Identifier of the thread.
1017+
- awaited_by (list[TaskInfo]): The running task and all its
1018+
transitive waiters.
1019+
1020+
Each TaskInfo contains:
1021+
- task_id (int): Identifier of the task.
1022+
- task_name (str): Name of the task.
1023+
- coroutine_stack (list[CoroInfo]): Stack of coroutine frames.
1024+
- awaited_by (list[CoroInfo]): Coroutine information for
1025+
tasks or futures awaiting this task.
1026+
1027+
Each CoroInfo contains:
1028+
- call_stack (list[FrameInfo]): Frames for the coroutine.
1029+
- task_name (int): Identifier of the task or future.
1030+
1031+
Each FrameInfo contains:
1032+
- filename (str): Source code filename.
1033+
- location (LocationInfo | None): Source location, if available.
1034+
- funcname (str): Function name.
1035+
- opcode (int | None): Opcode, if available.
1036+
1037+
Each LocationInfo contains:
1038+
- lineno (int): Starting line number.
1039+
- end_lineno (int): Ending line number.
1040+
- col_offset (int): Starting column offset.
1041+
- end_col_offset (int): Ending column offset.
10231042
10241043
Raises:
10251044
RuntimeError: If AsyncioDebug section is not available in the
10261045
target process
10271046
MemoryError: If memory allocation fails
10281047
OSError: If reading from the remote process fails
10291048
1030-
Example output (similar structure to get_all_awaited_by but only for
1031-
running tasks):
1032-
[
1033-
# Thread 140234 results
1034-
(140234, [
1035-
# Running task and its complete waiter dependency graph
1036-
(4345585712, 'main_task',
1037-
[("run_server", "server.py", 127), ("main", "app.py", 23)],
1038-
[
1039-
# Tasks waiting for main_task
1040-
(4345585800, 'worker_1', [...], [...]),
1041-
(4345585900, 'worker_2', [...], [...])
1042-
])
1043-
])
1044-
]
1049+
Example output:
1050+
1051+
[
1052+
AwaitedInfo(thread_id=140234, awaited_by=[
1053+
TaskInfo(
1054+
task_id=1,
1055+
task_name="worker",
1056+
coroutine_stack=[
1057+
CoroInfo(call_stack=[...], task_name=1)
1058+
],
1059+
awaited_by=[CoroInfo(call_stack=[...], task_name=2)]
1060+
),
1061+
TaskInfo(
1062+
task_id=2,
1063+
task_name="main",
1064+
coroutine_stack=[
1065+
CoroInfo(call_stack=[...], task_name=2)
1066+
],
1067+
awaited_by=[]
1068+
)
1069+
])
1070+
]
10451071
10461072
[clinic start generated code]*/
10471073

10481074
static PyObject *
10491075
_remote_debugging_RemoteUnwinder_get_async_stack_trace_impl(RemoteUnwinderObject *self)
1050-
/*[clinic end generated code: output=6433d52b55e87bbe input=bc802e4221c99399]*/
1076+
/*[clinic end generated code: output=6433d52b55e87bbe input=0532031a7c495491]*/
10511077
{
10521078
if (ensure_async_debug_offsets(self) < 0) {
10531079
return NULL;

0 commit comments

Comments
 (0)