Title: `asyncio.print_call_graph()` loses the call stack at anext(agen, default) · Issue #157032 · python/cpython · GitHub
Open Graph Title: `asyncio.print_call_graph()` loses the call stack at anext(agen, default) · Issue #157032 · python/cpython
X Title: `asyncio.print_call_graph()` loses the call stack at anext(agen, default) · Issue #157032 · python/cpython
Description: Bug report Bug description: Adding a default to anext() hides everything the generator is waiting on Repro: import asyncio async def deep(): await asyncio.Event().wait() async def rows(): await deep() yield 1 async def worker(): await an...
Open Graph Description: Bug report Bug description: Adding a default to anext() hides everything the generator is waiting on Repro: import asyncio async def deep(): await asyncio.Event().wait() async def rows(): await dee...
X Description: Bug report Bug description: Adding a default to anext() hides everything the generator is waiting on Repro: import asyncio async def deep(): await asyncio.Event().wait() async def rows(): await dee...
Opengraph URL: https://github.com/python/cpython/issues/157032
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`asyncio.print_call_graph()` loses the call stack at anext(agen, default)","articleBody":"# Bug report\n\n### Bug description:\n\nAdding a default to `anext()` hides everything the generator is waiting on\n\nRepro:\n\n```python\nimport asyncio\n\nasync def deep():\n await asyncio.Event().wait()\n\nasync def rows():\n await deep()\n yield 1\n\nasync def worker():\n await anext(rows(), None)\n\nasync def main():\n t = asyncio.create_task(worker(), name='worker')\n await asyncio.sleep(0.05)\n asyncio.print_call_graph(t)\n t.cancel()\n\nasyncio.run(main())\n```\n\nExpected:\n\n```\n* Task(name='worker', id=0x103a049b0)\n + Call stack:\n | File '/Users/timofeiivankov/cpython/Lib/asyncio/locks.py', line 210, in async Event.wait()\n | File '/Users/timofeiivankov/cpython/repro.py', line 4, in async deep()\n | File '/Users/timofeiivankov/cpython/repro.py', line 7, in async generator rows()\n | File '/Users/timofeiivankov/cpython/repro.py', line 11, in async worker()\n```\n\nActual:\n\n```\n* Task(name='worker', id=0x1035c89b0)\n + Call stack:\n | File '/Users/timofeiivankov/cpython/repro.py', line 11, in async worker()\n```\n\nProposed fix: expose `ag_gen` on `anext_awaitable` like https://github.com/python/cpython/pull/156984 do\n\n**Important:** Currently this issue have a blocker from https://github.com/python/cpython/pull/156984 (issue - #156980) because it depends on the fix of it. I have a fix ready and will open a PR once #156984 is merged\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nmacOS","author":{"url":"https://github.com/deadlovelll","@type":"Person","name":"deadlovelll"},"datePublished":"2026-09-06T11:06:11Z","url":"https://github.com/python/cpython/issues/157032"}
| 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:46cb5785-3666-e8a3-e472-203d416e8b37 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 833E:22DB35:494A867:5D3E148:6B023F3A |
| html-safe-nonce | 14c6872e63a9b4a6f97c936fb623a928b0fa495200e3eb811d08bef02da65de1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MzNFOjIyREIzNTo0OTRBODY3OjVEM0UxNDg6NkIwMjNGM0EiLCJ2aXNpdG9yX2lkIjoiNDU1MjEwNTM0OTEyOTMyMjI5OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | d9f1a92ef4cf0652a5097828d7ac4dc9e7f9d1d13ae5d9e98da2a221da79e50c |
| hovercard-subject-tag | issue:5364567107 |
| 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/157032/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5d7b674ca642a39c172a786dc0486e3f609fc2b22079d1b01a76b153cd86d04b/python/cpython/issues/157032 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5d7b674ca642a39c172a786dc0486e3f609fc2b22079d1b01a76b153cd86d04b/python/cpython/issues/157032 |
| og:image:alt | Bug report Bug description: Adding a default to anext() hides everything the generator is waiting on Repro: import asyncio async def deep(): await asyncio.Event().wait() async def rows(): await dee... |
| 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