]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-127258: Fix asyncio test_staggered_race_with_eager_tasks() (GH-127358)...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 29 Nov 2024 10:59:22 +0000 (11:59 +0100)
committerGitHub <noreply@github.com>
Fri, 29 Nov 2024 10:59:22 +0000 (10:59 +0000)
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 bfabf96b50b7d6a9c15b298a86ba3633b05a1fd7)

Co-authored-by: Victor Stinner <vstinner@python.org>
Lib/test/test_asyncio/test_eager_task_factory.py

index b06832e02f00d6a545eccf6e107a632274063bf2..e2a54dd8d768c8a5495364607de49ff94b9a0b31 100644 (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()
                 ],