Skip to content

_remote_debugging: incorrect docstring get_all_awaited_by() #149302

@maurycy

Description

@maurycy

Documentation

While writing a reproduction for #149230, I noted that get_all_awaited_by
docstring does not match reality:

_remote_debugging.RemoteUnwinder.get_all_awaited_by
Get all tasks and their awaited_by relationships from the remote process.
This provides a tree structure showing which tasks are waiting for other tasks.
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
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
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
[...]
]
]
]

It's not a list of [frames, task_name, subtasks] but (thread_id, awaited_by).

Reproduction

2026-05-03T01:17:12.666835000+0200 maurycy@gimel /Users/maurycy/src/github.com/maurycy/cpython (main 6b632ce?) % cat żółtagęślajaźń.py 
import asyncio
import os
from _remote_debugging import RemoteUnwinder
from pprint import pp


async def main():
    asyncio.create_task(asyncio.sleep(60), name="jaźńżółtejgęsi")
    await asyncio.sleep(0)
    pp(RemoteUnwinder(os.getpid()).get_all_awaited_by())


if __name__ == "__main__":
    asyncio.run(main())
2026-05-03T01:17:14.997344000+0200 maurycy@gimel /Users/maurycy/src/github.com/maurycy/cpython (main 6b632ce?) % uv run --python ./python.exe --with rich żółtagęślajaźń.py
[_remote_debugging.AwaitedInfo(thread_id=15788487, awaited_by=[_remote_debugging.TaskInfo(task_id=4399457888, task_name='Task-1', coroutine_stack=[_remote_debugging.CoroInfo(call_stack=[_remote_debugging.FrameInfo(filename='/Users/maurycy/src/github.com/maurycy/cpython/żółtagęślajaźń.py', location=_remote_debugging.LocationInfo(lineno=10, end_lineno=10, col_offset=7, end_col_offset=55), funcname='main', opcode=None)], task_name=4399457888)], awaited_by=[]), _remote_debugging.TaskInfo(task_id=4399407440, task_name='jaźńżółtejgęsi', coroutine_stack=[_remote_debugging.CoroInfo(call_stack=[_remote_debugging.FrameInfo(filename='/Users/maurycy/src/github.com/maurycy/cpython/Lib/asyncio/tasks.py', location=_remote_debugging.LocationInfo(lineno=702, end_lineno=702, col_offset=15, end_col_offset=27), funcname='sleep', opcode=None)], task_name=4399407440)], awaited_by=[])]),
 _remote_debugging.AwaitedInfo(thread_id=0, awaited_by=[])]

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions