Title: `asyncio.gather()` records its creator instead of the actual awaiting task in the call graph · Issue #162061 · python/cpython · GitHub
Open Graph Title: `asyncio.gather()` records its creator instead of the actual awaiting task in the call graph · Issue #162061 · python/cpython
X Title: `asyncio.gather()` records its creator instead of the actual awaiting task in the call graph · Issue #162061 · python/cpython
Description: Bug report The call graph shows who created gather(), rather than who awaits it Repro: import asyncio async def consume(future): await future async def main(): release = asyncio.Event() child = asyncio.create_task(release.wait(), name="c...
Open Graph Description: Bug report The call graph shows who created gather(), rather than who awaits it Repro: import asyncio async def consume(future): await future async def main(): release = asyncio.Event() child = asy...
X Description: Bug report The call graph shows who created gather(), rather than who awaits it Repro: import asyncio async def consume(future): await future async def main(): release = asyncio.Event() child = asy...
Opengraph URL: https://github.com/python/cpython/issues/162061
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`asyncio.gather()` records its creator instead of the actual awaiting task in the call graph","articleBody":"### Bug report\n\nThe call graph shows who created gather(), rather than who awaits it\n\nRepro:\n\n```python\nimport asyncio\n\n\nasync def consume(future):\n await future\n\n\nasync def main():\n release = asyncio.Event()\n child = asyncio.create_task(release.wait(), name=\"child\")\n wrapper = asyncio.gather(child)\n consumer = asyncio.create_task(consume(wrapper), name=\"consumer\")\n await asyncio.sleep(0)\n\n asyncio.print_call_graph(child)\n\n release.set()\n await consumer\n\n\nasyncio.run(main())\n```\n\nActual:\n\n```\n* Task(name='child', id=0x1056cc7d0)\n + Call stack:\n | File '/Users/timofeiivankov/cpython/Lib/asyncio/locks.py', line 210, in async Event.wait()\n + Awaited by:\n * Task(name='Task-1', id=0x1056cc5f0)\n + Call stack:\n | File '/Users/timofeiivankov/cpython/repro.py', line 15, in async main()\n```\n\nThe problem here that `child` is not awaited by the `main`, it's awaited by the `gather` which in his order is awaited by consumer. At the moment of the capturing call graph, no one of the tasks or futures is not awaited by `main`\n\nExpected:\n\n```\n* Task(name='child', id=0x101b1c7d0)\n + Call stack:\n | File '/Users/timofeiivankov/cpython/Lib/asyncio/locks.py', line 210, in async Event.wait()\n + Awaited by:\n * Future(id=0x1017b28d0)\n + Awaited by:\n * Task(name='consumer', id=0x101b003f0)\n + Call stack:\n | File '/Users/timofeiivankov/cpython/repro.py', line 5, in async consume()\n```\n\nProposed fix: link children to the future returned by gather() instead of the task that created it\n\nProblem: fix can be applied, but tests for the remote_debugging will fail, i already created https://github.com/python/cpython/pull/161508 for supportig Futures here, since it will be merged to main i'll be able to work on this issue\n\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-162394\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/deadlovelll","@type":"Person","name":"deadlovelll"},"datePublished":"2026-11-15T20:16:16Z","url":"https://github.com/python/cpython/issues/162061"}
| 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:9046cc0b-cd90-1d6c-f189-8ed9d534156b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A230:22DB35:39B47E5:499D2D8:6B01EC39 |
| html-safe-nonce | e967647fe1bd90da87d1573fed1a515fdf8a161806d2ae164febbf7ba15f6f48 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMjMwOjIyREIzNTozOUI0N0U1OjQ5OUQyRDg6NkIwMUVDMzkiLCJ2aXNpdG9yX2lkIjoiNzgwNzMzMzMwNDExNzYxOTc2OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | a7685f82d56915ddaa951f800ad7a88d51b97beeb781246ee4bfd555adbdb813 |
| hovercard-subject-tag | issue:6408969587 |
| 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/162061/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2b6dac78dc4c0ad42735e5126e2e2f2566d86229e6d700af40a99669c28112c9/python/cpython/issues/162061 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2b6dac78dc4c0ad42735e5126e2e2f2566d86229e6d700af40a99669c28112c9/python/cpython/issues/162061 |
| og:image:alt | Bug report The call graph shows who created gather(), rather than who awaits it Repro: import asyncio async def consume(future): await future async def main(): release = asyncio.Event() child = asy... |
| 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