Skip to content

asyncio.Task.print_stack() misses async generator frames #161178

Closed

Description

@deadlovelll

Bug report

Task.print_stack() returns an empty list for a pending task created from anext(), asend(), athrow(), or aclose().

import asyncio

async def gen():
    await asyncio.Future()
    yield

async def main():
    task = asyncio.create_task(anext(gen()))
    await asyncio.sleep(0)
    task.print_stack()

asyncio.run(main())

Actual output:

No stack for <Task pending name='Task-2' coro=<<async_generator_asend without __name__>()> wait_for=<Future pending cb=[Task.task_wakeup()]>>

Expected output:

Stack for <Task pending name='Task-2' coro=<<async_generator_asend without __name__>()> wait_for=<Future pending cb=[Task.task_wakeup()]>> (most recent call last):
  File "/Users/timofeiivankov/cpython/repro.py", line 4, in gen
    await asyncio.Future()

Proposed fix: support aga_gen that was added by gh-160837

I'll work on this

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Linked PRs

Activity

  1. added a commit that references this issue on Nov 2, 2026
  2. moved this from Todo to Done in asyncioon 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

    stdlibStandard Library Python modules in the Lib/ directorytopic-asynciotype-bugAn unexpected behavior, bug, or error

    Projects

    • Status
      Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions