GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — `asyncio.print_call_graph()` loses the call stack at synchronous generators · Issue #156988 · python/cpython

asyncio.print_call_graph() loses the call stack at synchronous generators #156988

New issue
Copy link
New issue
Copy link
Closed
Closed
asyncio.print_call_graph() loses the call stack at synchronous generators#156988
Copy link
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-asynciotype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@deadlovelll
deadlovelll
opened on Sep 5, 2026
Issue body actions

Bug report

Bug description:

A single synchronous generator on the stack hides the whole async call chain above it

Repro:

import asyncio

def page_ids(total):
    for i in range(total):
        if i == 100:
            print(asyncio.format_call_graph())
            return
        yield i

def collect():
    return list(page_ids(250))

async def fetch():
    return collect()

async def main():
    print('got', len(await fetch()), 'ids')

asyncio.run(main())

Actual output:

* Task(name='Task-1', id=0x103f78b90)
  + Call stack:
  |   File '/Users/timofeiivankov/cpython/repro.py', line 6, in generator page_ids()

Expected:

* Task(name='Task-1', id=0x103cd4b90)
  + Call stack:
  |   File '/Users/timofeiivankov/cpython/repro.py', line 6, in generator page_ids()
  |   File '/Users/timofeiivankov/cpython/repro.py', line 11, in collect()
  |   File '/Users/timofeiivankov/cpython/repro.py', line 14, in async fetch()
  |   File '/Users/timofeiivankov/cpython/repro.py', line 17, in async main()

Proposed fix: change is_async check

From: is_async = f.f_generator is not None to is_async = isinstance(f.f_generator, types.CoroutineType)

Have a fix ready for that

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Linked PRs

  • gh-156988: Fix asyncio call graph loss at sync generators #156991
  • [3.15] gh-156988: Fix asyncio call graph loss at sync generators #157004
  • [3.14] gh-156988: Fix asyncio call graph loss at sync generators #157005

Activity

  1. deadlovelll
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Sep 5, 2026
  2. aisk
    added
    topic-asyncio
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    on Sep 5, 2026
  3. github-project-automation
    added this to asyncioon Sep 5, 2026
  4. github-project-automation
    moved this to Todo in asyncioon Sep 5, 2026
  5. kumaraditya303
    added 2 commits that reference this issue on Sep 5, 2026

    gh-156988: Fix asyncio call graph breaking at sync generators (#156991)

    e208bf0

    [3.14] gh-156988: Fix asyncio call graph loss at sync generators (#15…

    b8ce418
  6. kumaraditya303
    closed this as completedon Sep 6, 2026
  7. github-project-automation
    moved this from Todo to Done in asyncioon Sep 6, 2026
  8. hugovk
    added a commit that references this issue on Sep 7, 2026

    [3.15] gh-156988: Fix asyncio call graph loss at sync generators (#15…

    5b9e06e
  9. clin1234
    added a commit that references this issue on Sep 12, 2026

    pythongh-156988: Fix asyncio call graph breaking at sync generators (p…

    3f6a918
  10. asvetlov
    added a commit that references this issue on Oct 28, 2026

    gh-000000: Address review findings for lazy coroutine materialization

    cf78343
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/ directoryStandard Library Python modules in the Lib/ directorytopic-asynciotype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    • asyncio
      Status
      Done
      Show more project fields

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402520 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.