Skip to content

RemoteUnwinder.get_async_stack_trace() docstring describes an incorrect return structure #161173

Closed

Description

@deadlovelll

Documentation

Currently docstring of get_async_stack_trace in _remote_debugging/module.c contains outdated data:

Returns a list of per-thread results, where each thread result
contains:
- Thread ID
- List of task information for the running task and all its waiters

Each task info contains:
- Task ID (memory address)
- Task name
- Call stack frames: List of (func_name, filename, lineno)
- List of tasks waiting for this task (recursive structure)

...

Example output (similar structure to get_all_awaited_by but only for
running tasks):
[
    # Thread 140234 results
    (140234, [
        # Running task and its complete waiter dependency graph
        (4345585712, 'main_task',
         [("run_server", "server.py", 127), ("main", "app.py", 23)],
         [
             # Tasks waiting for main_task
             (4345585800, 'worker_1', [...], [...]),
             (4345585900, 'worker_2', [...], [...])
         ])
    ])
]

You can check the actual one with this script:

import asyncio
import os
from pprint import pprint
from _remote_debugging import RemoteUnwinder

async def main():
    unwinder = RemoteUnwinder(os.getpid())
    pprint(unwinder.get_async_stack_trace())

asyncio.run(main())

Output:

[
    _remote_debugging.AwaitedInfo(
        thread_id=92820780,
        awaited_by=[
            _remote_debugging.TaskInfo(
                task_id=4386621392,
                task_name='Task-1',
                coroutine_stack=[
                    _remote_debugging.CoroInfo(
                        call_stack=[
                            _remote_debugging.FrameInfo(
                                filename='/Users/timofeiivankov/cpython/repro.py',
                                location=_remote_debugging.LocationInfo(
                                    lineno=8,
                                    end_lineno=8,
                                    col_offset=11,
                                    end_col_offset=43,
                                ),
                                funcname='main',
                                opcode=None,
                            ),
                        ],
                        task_name=4386621392,
                    ),
                ],
                awaited_by=[],
            ),
        ],
    ),
]

Proposed enhance: actualize docstrings

I'll work on this

Linked PRs

Activity

  1. added a commit that references this issue on Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions