gh-155418: Fix TaskGroup hang when a task cancels it before suspending - #155421
gh-155418: Fix TaskGroup hang when a task cancels it before suspending#155421deadlovelll wants to merge 2 commits into
Conversation
| await asyncio.sleep(10) | ||
|
|
||
| async with asyncio.TaskGroup() as tg: | ||
| task = tg.create_task(child(tg)) |
There was a problem hiding this comment.
Maybe use your reproducer with the print as well? could be useful to catch (instead of print, just use a list and mutate it)
There was a problem hiding this comment.
thanks! just pushed the changes
| tg.cancel() | ||
| await asyncio.sleep(10) | ||
|
|
||
| async with asyncio.TaskGroup() as tg: |
There was a problem hiding this comment.
I thought the problem was with the eager task factory?
There was a problem hiding this comment.
hi! if i understand you well - BaseTestTaskGroup class that stores all of the tests is not inheriting from unittests TestCase https://github.com/deadlovelll/cpython/blob/62ab3f87bdb17aafa97e44fd26386893ead0497b/Lib/test/test_asyncio/test_taskgroups.py#L60.
Runners are TestTaskGroup and TestEagerTaskTaskGroup that inherits from BaseTestTaskGroup and unittest.IsolatedAsyncioTestCase, they are located at the bottom of the file https://github.com/deadlovelll/cpython/blob/62ab3f87bdb17aafa97e44fd26386893ead0497b/Lib/test/test_asyncio/test_taskgroups.py#L1307-L1315
TestEagerTaskTaskGroup already inject eager factory for this
Fix TaskGroup hang when a task cancels it before suspending
For more details see gh-155418