← 输入框|github.com|刷新
Skip to content

asyncio call graph is truncated at async generators #160837

Open

Description

@msullivan

Bug report

This was originally filed by Timofey Ivankov (@deadlovelll), whose gh account is frozen currently, so I'm refiling it and will repost the PR.

import asyncio

fut = None

async def deep():
    await fut

async def gen():
    await deep()
    yield 1

async def consumer():
    async for _ in gen():
        pass

async def main():
    global fut
    fut = asyncio.get_running_loop().create_future()
    t = asyncio.create_task(consumer(), name='consumer')
    for _ in range(5):
        await asyncio.sleep(0)
    asyncio.print_call_graph(t)
    fut.set_result(None)
    await t

asyncio.run(main())

This prints:

* Task(name='consumer', id=0xe6e7055556d0)
  + Call stack:
  |   File '/home/sully/asyncgen-callgraph.py', line 13, in async consumer()

and we'd like it to print the whole stack like:

* Task(name='consumer', id=0xf7a46909e210)
  + Call stack:
  |   File '/home/sully/asyncgen-callgraph.py', line 6, in async deep()
  |   File '/home/sully/asyncgen-callgraph.py', line 9, in async generator gen()
  |   File '/home/sully/asyncgen-callgraph.py', line 13, in async consumer()

CPython versions tested on:

CPython main branch, 3.15

Operating systems tested on:

No response

Linked PRs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

  • Status
    Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions