Title: `python -m asyncio pstree` loses nodes on Task → Future → Task chains · Issue #161502 · python/cpython · GitHub
Open Graph Title: `python -m asyncio pstree` loses nodes on Task → Future → Task chains · Issue #161502 · python/cpython
X Title: `python -m asyncio pstree` loses nodes on Task → Future → Task chains · Issue #161502 · python/cpython
Description: Bug report When one task awaits another through a Future, python -m asyncio pstree omits the awaited task from the tree Repro: import asyncio import os async def main(): asyncio.current_task().set_name("main") task = asyncio.create_task(...
Open Graph Description: Bug report When one task awaits another through a Future, python -m asyncio pstree omits the awaited task from the tree Repro: import asyncio import os async def main(): asyncio.current_task().set_...
X Description: Bug report When one task awaits another through a Future, python -m asyncio pstree omits the awaited task from the tree Repro: import asyncio import os async def main(): asyncio.current_task().set_...
Opengraph URL: https://github.com/python/cpython/issues/161502
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`python -m asyncio pstree` loses nodes on Task → Future → Task chains","articleBody":"### Bug report\n\nWhen one task awaits another through a Future, `python -m asyncio pstree` omits the awaited task from the tree\n\nRepro:\n\n```python\nimport asyncio\nimport os\n\nasync def main():\n asyncio.current_task().set_name(\"main\")\n task = asyncio.create_task(asyncio.sleep(3600), name=\"worker\")\n future = asyncio.get_running_loop().create_future()\n asyncio.future_add_to_awaited_by(task, future)\n task.add_done_callback(future.set_result)\n print(os.getpid(), flush=True)\n try:\n await future\n finally:\n asyncio.future_discard_from_awaited_by(task, future)\n\n\nasyncio.run(main())\n```\n\nRun:\n\n```\nsudo ./python.exe -m asyncio pstree \u003cPID>\n```\n\nOutput:\n\n```\n└── (T) main\n └── main /Users/timofeiivankov/cpython/repro.py:12\n```\n\nExpected output:\n\n```\n└── (T) main\n └── main /Users/timofeiivankov/cpython/repro.py:12\n └── (F) Future-0x104e82a80\n └── (T) worker\n └── sleep /Users/timofeiivankov/cpython/Lib/asyncio/tasks.py:733\n```\n\nFor example `asyncio.print_call_graph()` works with this well:\n\n```python\nimport asyncio\n\nasync def worker():\n asyncio.print_call_graph(limit=0)\n \nasync def main():\n asyncio.current_task().set_name(\"main\")\n task = asyncio.create_task(worker(), name=\"worker\")\n future = asyncio.get_running_loop().create_future()\n asyncio.future_add_to_awaited_by(task, future)\n task.add_done_callback(future.set_result)\n try:\n await future\n finally:\n asyncio.future_discard_from_awaited_by(task, future)\n\nasyncio.run(main())\n```\n\n```\n* Task(name='worker', id=0x1014d47d0)\n + Awaited by:\n * Future(id=0x10115ea80)\n + Awaited by:\n * Task(name='main', id=0x1014d45f0)\n```\n\nProposed fix: add Future support in the _remote_debugging\n\nI'll work on this\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-161508\n* gh-162338\n* gh-162339\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/deadlovelll","@type":"Person","name":"deadlovelll"},"datePublished":"2026-11-06T16:44:02Z","url":"https://github.com/python/cpython/issues/161502"}
| 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:24c3c8e1-3694-8bc1-224a-23b3c33f08ee |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CDAC:2DBB21:32A346E:4397925:6B01F774 |
| html-safe-nonce | 75d559acba35d03724708bf6a6159244c41442d40b28d493b81148b320bb5069 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDREFDOjJEQkIyMTozMkEzNDZFOjQzOTc5MjU6NkIwMUY3NzQiLCJ2aXNpdG9yX2lkIjoiNjM0MTc2NzExMTI2MTY4MTUyNCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 2c2d2aaa0c2ee9e921a35c941c6d821617b16ccf2b13159469ebcca08ce73081 |
| hovercard-subject-tag | issue:6246768398 |
| 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/161502/issue_layout |
| twitter:image | https://opengraph.githubassets.com/49f393c9fb1a8415f451b6feec7c59ae6970ad5bb961f247da8fb8c45c1efed4/python/cpython/issues/161502 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/49f393c9fb1a8415f451b6feec7c59ae6970ad5bb961f247da8fb8c45c1efed4/python/cpython/issues/161502 |
| og:image:alt | Bug report When one task awaits another through a Future, python -m asyncio pstree omits the awaited task from the tree Repro: import asyncio import os async def main(): asyncio.current_task().set_... |
| 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