Title: [asyncio] cancelling task cancels awaited task instead · Issue #138717 · python/cpython · GitHub
Open Graph Title: [asyncio] cancelling task cancels awaited task instead · Issue #138717 · python/cpython
X Title: [asyncio] cancelling task cancels awaited task instead · Issue #138717 · python/cpython
Description: The issue boils down to this line: cpython/Lib/asyncio/tasks.py Line 215 in 6bc65c3 if self._fut_waiter.cancel(msg=msg): First off the bat, I realize this may be impossible to change due to backwards comp. Still, let's discuss. Task A aw...
Open Graph Description: The issue boils down to this line: cpython/Lib/asyncio/tasks.py Line 215 in 6bc65c3 if self._fut_waiter.cancel(msg=msg): First off the bat, I realize this may be impossible to change due to backwar...
X Description: The issue boils down to this line: cpython/Lib/asyncio/tasks.py Line 215 in 6bc65c3 if self._fut_waiter.cancel(msg=msg): First off the bat, I realize this may be impossible to change due to backwar...
Opengraph URL: https://github.com/python/cpython/issues/138717
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[asyncio] cancelling task cancels awaited task instead","articleBody":"The issue boils down to this line: https://github.com/python/cpython/blob/6bc65c30ff1fd0b581a2c93416496fc720bc442c/Lib/asyncio/tasks.py#L215\n\nFirst off the bat, I realize this may be impossible to change due to backwards comp. Still, let's discuss.\n\nTask A awaits task B. Someone cancels task A. Task B gets cancelled instead.\n\nThis probably makes sense in some contexts, for example if task A is the logical owner/parent of task B.\nBut in my case, task B was created in a long-lived taskgroup. Its lifecycle is independent of task A. They are now coupled by this invisible link created by the await.\n\nI wonder if we could make this cancellation forwarding be skipped in some cases, like if the awaitee was created through a task group (since that mitigates the danger of leaking tasks).","author":{"url":"https://github.com/Tinche","@type":"Person","name":"Tinche"},"datePublished":"2025-09-09T20:58:16.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/138717/cpython/issues/138717"}
| 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:a8dcd682-1297-913d-fc53-c5640200ad1a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8F96:39978:A6DFAB8:AA6A188:6A50BA99 |
| html-safe-nonce | f3b70813c0a81fe0e4973b3ac9a738823f2900f66ef6a361ad806af329ab0617 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4Rjk2OjM5OTc4OkE2REZBQjg6QUE2QTE4ODo2QTUwQkE5OSIsInZpc2l0b3JfaWQiOiIzNjczOTgwMDYxMTc2ODcxNTc3IiwicmVnaW9uX2VkZ2UiOiJzZWEiLCJyZWdpb25fcmVuZGVyIjoic2VhIn0= |
| visitor-hmac | aa0b51d218e79786dd1c92ebb44a7f37f31daaf7d772f9648a8b1a9c4a92a9a4 |
| hovercard-subject-tag | issue:3399927091 |
| 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/138717/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d177f9ac77f169e19cdddb0289d97582d1cd7767eca97108b7d434911f89fa4d/python/cpython/issues/138717 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d177f9ac77f169e19cdddb0289d97582d1cd7767eca97108b7d434911f89fa4d/python/cpython/issues/138717 |
| og:image:alt | The issue boils down to this line: cpython/Lib/asyncio/tasks.py Line 215 in 6bc65c3 if self._fut_waiter.cancel(msg=msg): First off the bat, I realize this may be impossible to change due to backwar... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Tinche |
| hostname | github.com |
| expected-hostname | github.com |
| None | 72b13e0e8d0319acdd27a145cfe73f4f06c791713d0ac4690e41fb68ad28cac0 |
| 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 | 08e79d53fc070870d5b168356afebb1e286a2ffe |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width