Closed
Description
Bug report
Bug description:
asyncio's staggered_race
crashes when an eager task factory is being used:
import asyncio
async def main():
asyncio.get_running_loop().set_task_factory(asyncio.eager_task_factory)
await asyncio.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
- gh-124309: Fix the AssertionError when using the happy_eyeballs_delay argument in open_connection #124311
- gh-124309: Modernize the
staggered_race
implementation to support eager task factories #124390 - [3.13] gh-124309: Modernize the
staggered_race
implementation to support eager task factories (GH-124390) #124573 - [3.12] gh-124309: Modernize the
staggered_race
implementation to support e… #124574 - gh-124309: Revert eager task factory fix to prevent breaking downstream #124810
- [3.12] gh-124309: Revert eager task factory fix to prevent breaking downstream (GH-124810) #124817
- gh-124309: fix staggered race on eager tasks #124847
- [3.13] gh-124309: fix staggered race on eager tasks (GH-124847) #125339
- [3.12] gh-124309: fix staggered race on eager tasks (GH-124847) #125340
Metadata
Metadata
Assignees
Labels
only security fixesonly security fixesbugs and security fixesbugs and security fixesbugs and security fixesbugs and security fixesPython modules in the Lib dirPython modules in the Lib dirAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Projects
Status
Done