Title: `asyncio.print_call_graph()` loses the call stack at synchronous generators · Issue #156988 · python/cpython · GitHub
Open Graph Title: `asyncio.print_call_graph()` loses the call stack at synchronous generators · Issue #156988 · python/cpython
X Title: `asyncio.print_call_graph()` loses the call stack at synchronous generators · Issue #156988 · python/cpython
Description: 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 yi...
Open Graph Description: 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: prin...
X Description: 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: prin...
Opengraph URL: https://github.com/python/cpython/issues/156988
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`asyncio.print_call_graph()` loses the call stack at synchronous generators","articleBody":"# Bug report\n\n### Bug description:\n\nA single synchronous generator on the stack hides the whole async call chain above it\n\nRepro:\n\n```python\nimport asyncio\n\ndef page_ids(total):\n for i in range(total):\n if i == 100:\n print(asyncio.format_call_graph())\n return\n yield i\n\ndef collect():\n return list(page_ids(250))\n\nasync def fetch():\n return collect()\n\nasync def main():\n print('got', len(await fetch()), 'ids')\n\nasyncio.run(main())\n```\n\nActual output:\n\n```\n* Task(name='Task-1', id=0x103f78b90)\n + Call stack:\n | File '/Users/timofeiivankov/cpython/repro.py', line 6, in generator page_ids()\n```\n\nExpected:\n\n```\n* Task(name='Task-1', id=0x103cd4b90)\n + Call stack:\n | File '/Users/timofeiivankov/cpython/repro.py', line 6, in generator page_ids()\n | File '/Users/timofeiivankov/cpython/repro.py', line 11, in collect()\n | File '/Users/timofeiivankov/cpython/repro.py', line 14, in async fetch()\n | File '/Users/timofeiivankov/cpython/repro.py', line 17, in async main()\n```\n\nProposed fix: change `is_async` check\n\nFrom: ```is_async = f.f_generator is not None``` to ```is_async = isinstance(f.f_generator, types.CoroutineType)```\n\nHave a fix ready for that\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nmacOS\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-156991\n* gh-157004\n* gh-157005\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/deadlovelll","@type":"Person","name":"deadlovelll"},"datePublished":"2026-09-05T15:16:04Z","url":"https://github.com/python/cpython/issues/156988"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a252b89e-4917-1780-1153-fa9852fcfc6d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C15A:33444D:333A664:441F8EA:6B01F79E |
| html-safe-nonce | c15d2aa23a556486025bb43e023aa1e03bb4845a734a6f803d865b094092d1e8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMTVBOjMzNDQ0RDozMzNBNjY0OjQ0MUY4RUE6NkIwMUY3OUUiLCJ2aXNpdG9yX2lkIjoiMzM0OTk4MjU5NzU1NTAyNTgyMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | d47967f845b974c364ce8345507772022284f4bcf74063562f52e4a4d9f08586 |
| hovercard-subject-tag | issue:5358887600 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/156988/issue_layout |
| twitter:image | https://opengraph.githubassets.com/bc8931b6c7608bf53351669bd272ad4b9a4b80ad629d85c012a56f7976eda7fe/python/cpython/issues/156988 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/bc8931b6c7608bf53351669bd272ad4b9a4b80ad629d85c012a56f7976eda7fe/python/cpython/issues/156988 |
| og:image:alt | 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: prin... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | deadlovelll |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width