Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
gh-128550: TaskGroup: cancel tasks added to set after aborting#128551
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
9726c3d98b6d01f9838346f661beca5593b1f3e028dfdee7db1d15b6b3a20dbb777cf4b09c9e058445e7c4842d9File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1040,6 +1040,32 @@ class MyKeyboardInterrupt(KeyboardInterrupt): | ||
| self.assertIsNotNone(exc) | ||
| self.assertListEqual(gc.get_referrers(exc), no_other_refs()) | ||
| async def test_cancels_task_if_created_during_creation(self): | ||
graingert marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading. Please reload this page.
graingert marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading. Please reload this page. | ||
| # regression test for gh-128550 | ||
| ran = False | ||
| class MyError(Exception): | ||
| pass | ||
| exc = None | ||
| try: | ||
graingert marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading. Please reload this page. | ||
| async with asyncio.TaskGroup() as tg: | ||
| async def third_task(): | ||
| raise MyError("third task failed") | ||
| async def second_task(): | ||
| nonlocal ran | ||
| tg.create_task(third_task()) | ||
| with self.assertRaises(asyncio.CancelledError): | ||
| await asyncio.sleep(0) # eager tasks cancel here | ||
| await asyncio.sleep(0) # lazy tasks cancel here | ||
| ran = True | ||
| tg.create_task(second_task()) | ||
| except* MyError as excs: | ||
| exc = excs.exceptions[0] | ||
graingert marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading. Please reload this page. | ||
| self.assertTrue(ran) | ||
graingert marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading. Please reload this page.
graingert marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading. Please reload this page. | ||
| self.assertIsInstance(exc, MyError) | ||
| class TestTaskGroup(BaseTestTaskGroup, unittest.IsolatedAsyncioTestCase): | ||
| loop_factory = asyncio.EventLoop | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Fix a deadlock in :class:`asyncio.TaskGroup` when using eager tasks that abort the task group too early. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.