Repository navigation
Happy Eyeballs crashes with Eager Task Factory #124309
Description
Activity
- addedtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
on Sep 22, 2024 - addedstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
on Sep 22, 2024 I'd love to help you, but what I can't understand is why it creates an extra task that triggers the assertion.
next_task = loop.create_task(run_one_coro(this_failed)) running_tasks.append(next_task) print('\n', 'HELLO', len(running_tasks), this_index) assert len(running_tasks) == this_index + 2 # Prepare place to put this coroutine's exceptions if not won exceptions.append(None) assert len(exceptions) == this_index + 1HELLO 1 1 HELLO 3 2Maybe you can start from here, sorry I'm not familiar with this.
Probably removing that assert is sufficient.
Probably removing that assert is sufficient.
Removing that assertion won't fix the issue; instead, it could cause new errors elsewhere. the real problem isn't with the assertion anyway.
- added3.12only security fixesonly security fixes3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixes
on Sep 23, 2024 This issue is unrelated to Happy Eyeballs, but instead that
staggered_racedoesn't supporteager_task_factory. Seperate reproducer:import asyncio import random async def main(): asyncio.get_running_loop().set_task_factory(asyncio.eager_task_factory) await asyncio.staggered.staggered_race([lambda: asyncio.sleep(0) for _ in range(5)], 0.25) asyncio.run(main())
Using -O (to disable assertions) is a workaround for all versions, but maybe it's worth revisiting
staggered_racea little bit to make sure it's working correctly with eager task factory. I'm working on that.Ah, using
delay=Nonein my reproducer causes a deadlock. Removing the assertion isn't 100% effective.I've created #124390 as a fix. The existing implementation was so broken for eager task factories (due to the reliance of tasks not starting before you
awaitthem), so I had to pretty much rewrite it.Could you confirm that it solves your problem, @mhils?
That's right, I was confused when I tried to fix it, I kept thinking that maybe it was supporting
eager_task_factory.8 remaining items
Sorry, we had to revert the fix due to the complexity of it (and also because it was causing some other problems). We'll (hopefully) have the fix for this issue in the next-next 3.12 patch (not tomorrow's, the one after, so 3.12.8).
- added a commit that references this issue
on Oct 1, 2024 - added a commit that references this issue
on Oct 11, 2024 I think this can be closed, it's backported to 3.12 and 3.13
- added 2 commits that reference this issue
on Aug 19, 2026
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsDone
Bug report
Bug description:
asyncio's
staggered_racecrashes when an eager task factory is being used:See also: aio-libs/aiohttp#8599
CPython versions tested on:
3.12
Operating systems tested on:
macOS
Linked PRs
staggered_raceimplementation to support eager task factories #124390staggered_raceimplementation to support eager task factories (GH-124390) #124573staggered_raceimplementation to support e… #124574