Skip to content

gh-155418: Fix TaskGroup hang when a task cancels it before suspending - #155421

Open
deadlovelll wants to merge 2 commits into
python:mainfrom
deadlovelll:gh-155418-tg-hang
Open

gh-155418: Fix TaskGroup hang when a task cancels it before suspending#155421
deadlovelll wants to merge 2 commits into
python:mainfrom
deadlovelll:gh-155418-tg-hang

Conversation

@deadlovelll

Copy link
Copy Markdown
Contributor

Fix TaskGroup hang when a task cancels it before suspending

For more details see gh-155418

await asyncio.sleep(10)

async with asyncio.TaskGroup() as tg:
task = tg.create_task(child(tg))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe use your reproducer with the print as well? could be useful to catch (instead of print, just use a list and mutate it)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! just pushed the changes

tg.cancel()
await asyncio.sleep(10)

async with asyncio.TaskGroup() as tg:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the problem was with the eager task factory?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants