[3.12] gh-127258: Fix asyncio test_staggered_race_with_eager_tasks() (GH-127358) (#127402)

gh-127258: Fix asyncio test_staggered_race_with_eager_tasks() (GH-127358)

Replace the sleep(2) with a task which is blocked forever.
(cherry picked from commit bfabf96b50)

Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
Miss Islington (bot) 2024-11-29 11:59:22 +01:00 committed by GitHub
parent 91399c3984
commit fc6c2de6de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -225,10 +225,14 @@ class EagerTaskFactoryLoopTests:
await asyncio.sleep(0)
raise ValueError("no good")
async def blocked():
fut = asyncio.Future()
await fut
async def run():
winner, index, excs = await asyncio.staggered.staggered_race(
[
lambda: asyncio.sleep(2, result="sleep2"),
lambda: blocked(),
lambda: asyncio.sleep(1, result="sleep1"),
lambda: fail()
],