Skip to content
Open
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
49 changes: 25 additions & 24 deletions Modules/_remote_debugging/clinic/module.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 24 additions & 28 deletions Modules/_remote_debugging/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -718,54 +718,50 @@ _remote_debugging_RemoteUnwinder_get_stack_trace_impl(RemoteUnwinderObject *self
}

/*[clinic input]
@permit_long_summary
@permit_long_docstring_body
@critical_section
_remote_debugging.RemoteUnwinder.get_all_awaited_by

Get all tasks and their awaited_by relationships from the remote process.
Get awaited_by relationships for tasks in the remote process.

This provides a tree structure showing which tasks are waiting for other tasks.
Returns:
A list of AwaitedInfo objects, where each object contains:

For each task, returns:
1. The call stack frames leading to where the task is currently executing
2. The name of the task
3. A list of tasks that this task is waiting for, with their own frames/names/etc
- thread_id (int): Identifier of the thread.
- awaited_by (list[TaskInfo]): List of TaskInfo objects representing tasks
awaiting this thread.

Returns a list of [frames, task_name, subtasks] where:
- frames: List of (func_name, filename, lineno) showing the call stack
- task_name: String identifier for the task
- subtasks: List of tasks being awaited by this task, in same format
Each TaskInfo contains:
- task_id (int): Identifier of the task.
- task_name (str): Name of the task.
- coroutine_stack (list[CoroInfo]): Stack of coroutine frames.
- awaited_by (list[TaskInfo]): Nested tasks awaited by this task.

Raises:
RuntimeError: If AsyncioDebug section is not available in the remote process
MemoryError: If memory allocation fails
OSError: If reading from the remote process fails

Example output:
[
# Task c2_root waiting for two subtasks

[
# Call stack of c2_root
[("c5", "script.py", 10), ("c4", "script.py", 14)],
"c2_root",
[
# First subtask (sub_main_2) and what it's waiting for
[
[("c1", "script.py", 23)],
"sub_main_2",
[...]
],
# Second subtask and its waiters
[...]
]
AwaitedInfo(
thread_id=12345,
awaited_by=[
TaskInfo(
task_id=1,
task_name="Task-1",
coroutine_stack=[...],
awaited_by=[]
)
]
)
]
]
[clinic start generated code]*/

static PyObject *
_remote_debugging_RemoteUnwinder_get_all_awaited_by_impl(RemoteUnwinderObject *self)
/*[clinic end generated code: output=6a49cd345e8aec53 input=307f754cbe38250c]*/
/*[clinic end generated code: output=6a49cd345e8aec53 input=71432c74fb386a75]*/
{
if (ensure_async_debug_offsets(self) < 0) {
return NULL;
Expand Down
Loading