summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2023-09-08 17:02:57 (GMT)
committerGitHub <noreply@github.com>2023-09-08 17:02:57 (GMT)
commit6b2f44ea7860bc9957e1f48ecddedff7a973876d (patch)
tree8e801f193ce6a8e13090d819b2d004726fd415b2
parentc1a2ef5efceda2705919ee0233ff657575909ce9 (diff)
downloadcpython-6b2f44ea7860bc9957e1f48ecddedff7a973876d.zip
cpython-6b2f44ea7860bc9957e1f48ecddedff7a973876d.tar.gz
cpython-6b2f44ea7860bc9957e1f48ecddedff7a973876d.tar.bz2
[3.11] GH-109067: fix randomly failing `test_async_gen_asyncio_gc_aclose_09` test (GH-109142) (#109150)
GH-109067: fix randomly failing `test_async_gen_asyncio_gc_aclose_09` test (GH-109142) Use `asyncio.sleep(0)` instead of short sleeps. (cherry picked from commit ccd48623d4860e730a16f3f252d67bfea8c1e905) Co-authored-by: Kumar Aditya <kumaraditya@python.org>
-rw-r--r--Lib/test/test_asyncgen.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/test/test_asyncgen.py b/Lib/test/test_asyncgen.py
index fb22f41..2241b39 100644
--- a/Lib/test/test_asyncgen.py
+++ b/Lib/test/test_asyncgen.py
@@ -1037,8 +1037,7 @@ class AsyncGenAsyncioTest(unittest.TestCase):
while True:
yield 1
finally:
- await asyncio.sleep(0.01)
- await asyncio.sleep(0.01)
+ await asyncio.sleep(0)
DONE = 1
async def run():
@@ -1048,7 +1047,10 @@ class AsyncGenAsyncioTest(unittest.TestCase):
del g
gc_collect() # For PyPy or other GCs.
- await asyncio.sleep(0.1)
+ # Starts running the aclose task
+ await asyncio.sleep(0)
+ # For asyncio.sleep(0) in finally block
+ await asyncio.sleep(0)
self.loop.run_until_complete(run())
self.assertEqual(DONE, 1)