Title: Cancellation leaks out of asyncio.TaskGroup on 3.12 when using eager tasks · Issue #128588 · python/cpython · GitHub
Open Graph Title: Cancellation leaks out of asyncio.TaskGroup on 3.12 when using eager tasks · Issue #128588 · python/cpython
X Title: Cancellation leaks out of asyncio.TaskGroup on 3.12 when using eager tasks · Issue #128588 · python/cpython
Description: Bug report Bug description: import sys import asyncio if sys.platform == "win32": EventLoop = asyncio.ProactorEventLoop else: EventLoop = asyncio.SelectorEventLoop async def demo(): class MyError(Exception): pass async def throw_error():...
Open Graph Description: Bug report Bug description: import sys import asyncio if sys.platform == "win32": EventLoop = asyncio.ProactorEventLoop else: EventLoop = asyncio.SelectorEventLoop async def demo(): class MyError(E...
X Description: Bug report Bug description: import sys import asyncio if sys.platform == "win32": EventLoop = asyncio.ProactorEventLoop else: EventLoop = asyncio.SelectorEventLoop async def demo(): class...
Opengraph URL: https://github.com/python/cpython/issues/128588
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Cancellation leaks out of asyncio.TaskGroup on 3.12 when using eager tasks","articleBody":"# Bug report\n\n### Bug description:\n\n```python\nimport sys\nimport asyncio\n\nif sys.platform == \"win32\":\n EventLoop = asyncio.ProactorEventLoop\nelse:\n EventLoop = asyncio.SelectorEventLoop\n\n\nasync def demo():\n class MyError(Exception):\n pass\n\n async def throw_error():\n raise MyError\n\n try:\n async with asyncio.TaskGroup() as tg:\n tg.create_task(throw_error())\n except* MyError:\n pass\n\n\ndef loop_factory():\n loop = EventLoop()\n loop.set_task_factory(asyncio.eager_task_factory)\n return loop\n\nasyncio.run(demo(), loop_factory=loop_factory)\n```\n\nresults in:\n```pytb\nTraceback (most recent call last):\n File \"/home/graingert/projects/anyio/demo.py\", line 29, in \u003cmodule\u003e\n asyncio.run(demo(), loop_factory=loop_factory)\n File \"/usr/lib/python3.12/asyncio/runners.py\", line 194, in run\n return runner.run(main)\n ^^^^^^^^^^^^^^^^\n File \"/usr/lib/python3.12/asyncio/runners.py\", line 118, in run\n return self._loop.run_until_complete(task)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/usr/lib/python3.12/asyncio/base_events.py\", line 687, in run_until_complete\n return future.result()\n ^^^^^^^^^^^^^^^\nasyncio.exceptions.CancelledError\n```\n\n### CPython versions tested on:\n\n3.12\n\n### Operating systems tested on:\n\nLinux\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-129063\n* gh-129089\n* gh-128586\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/graingert","@type":"Person","name":"graingert"},"datePublished":"2025-01-07T13:52:17.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/128588/cpython/issues/128588"}
| 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:fcf69fb7-bd30-8fdf-893e-a8eabebaf89b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9A82:367724:5861F4:729381:696B45EA |
| html-safe-nonce | 648c94a25976e467cb90c4f5d9fce6ef97fb1735eafa5a5da4cacdf3b94cd064 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QTgyOjM2NzcyNDo1ODYxRjQ6NzI5MzgxOjY5NkI0NUVBIiwidmlzaXRvcl9pZCI6IjU2MTA4NjM2MTcwNDk4MzkwODIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 3a4108465a20949f6de385f77c6fbb43396d719f68f3d83525712081ad3acd4c |
| hovercard-subject-tag | issue:2772905335 |
| 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/128588/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b38afe97ae995123973dfdf71796146c781cb56a21b2f033c22622190826a786/python/cpython/issues/128588 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b38afe97ae995123973dfdf71796146c781cb56a21b2f033c22622190826a786/python/cpython/issues/128588 |
| og:image:alt | Bug report Bug description: import sys import asyncio if sys.platform == "win32": EventLoop = asyncio.ProactorEventLoop else: EventLoop = asyncio.SelectorEventLoop async def demo(): class MyError(E... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | graingert |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| 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 | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width