Skip to content

Happy Eyeballs crashes with Eager Task Factory#124309

@mhils

Description

@mhils

Bug report

Bug description:

asyncio's staggered_race crashes when an eager task factory is being used:

importasyncioasyncdefmain(): asyncio.get_running_loop().set_task_factory(asyncio.eager_task_factory) awaitasyncio.open_connection("example.com", 80, happy_eyeballs_delay=0.25) asyncio.run(main())
Traceback (most recent call last): [...] File "/tmp/repro.py", line 5, in main await asyncio.open_connection("example.com", 80, happy_eyeballs_delay=0.25) File "/opt/homebrew/Cellar/python@3.12/3.12.6/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/streams.py", line 48, in open_connection transport, _ = await loop.create_connection( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/python@3.12/3.12.6/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 1109, in create_connection sock, _, _ = await staggered.staggered_race( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/python@3.12/3.12.6/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/staggered.py", line 144, in staggered_race raise d.exception() File "/opt/homebrew/Cellar/python@3.12/3.12.6/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/staggered.py", line 101, in run_one_coro assert len(running_tasks) == this_index + 2 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AssertionError 

See also: aio-libs/aiohttp#8599

CPython versions tested on:

3.12

Operating systems tested on:

macOS

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixes3.13bugs and security fixes3.14bugs and security fixesstdlibStandard Library Python modules in the Lib/ directorytopic-asynciotype-bugAn unexpected behavior, bug, or error

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions