Skip to content

asyncio.print_call_graph() loses the call stack at aiter(callable, stop_value) #157044

Description

@deadlovelll

Bug report

Bug description:

The two-argument form of aiter() hides everything the callable is waiting on. The awaitable it produces exposes nothing about the coroutine it wraps, so the walk stops there

Repro:

import asyncio

async def deep():
    await asyncio.Event().wait()

async def produce():
    await deep()
    return 1

async def worker():
    async for _ in aiter(produce, None):
        pass

async def main():
    t = asyncio.create_task(worker(), name='worker')
    await asyncio.sleep(0.05)
    asyncio.print_call_graph(t)
    t.cancel()

asyncio.run(main())

Expected:

* Task(name='worker', id=0x105e7cb90)
  + Call stack:
  |   File '/Users/timofeiivankov/cpython/Lib/asyncio/locks.py', line 210, in async Event.wait()
  |   File '/Users/timofeiivankov/cpython/repro.py', line 4, in async deep()
  |   File '/Users/timofeiivankov/cpython/repro.py', line 7, in async produce()
  |   File '/Users/timofeiivankov/cpython/repro.py', line 11, in async worker()

Actual:

* Task(name='worker', id=0x105adcb90)
  + Call stack:
  |   File '/Users/timofeiivankov/cpython/repro.py', line 11, in async worker()

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Activity

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
      Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions