diff options
author | Kumar Aditya <kumaraditya@python.org> | 2023-09-08 16:27:58 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-08 16:27:58 (GMT) |
commit | ccd48623d4860e730a16f3f252d67bfea8c1e905 (patch) | |
tree | 4a627fca257f78fd7431a67a802f2febbef7cf1d | |
parent | 52beebc856fedf507ac0eb9e45c2e2c9fed1e5b8 (diff) | |
download | cpython-ccd48623d4860e730a16f3f252d67bfea8c1e905.zip cpython-ccd48623d4860e730a16f3f252d67bfea8c1e905.tar.gz cpython-ccd48623d4860e730a16f3f252d67bfea8c1e905.tar.bz2 |
GH-109067: fix randomly failing `test_async_gen_asyncio_gc_aclose_09` test (#109142)
Use `asyncio.sleep(0)` instead of short sleeps.
-rw-r--r-- | Lib/test/test_asyncgen.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/test/test_asyncgen.py b/Lib/test/test_asyncgen.py index 4f00558..a496301 100644 --- a/Lib/test/test_asyncgen.py +++ b/Lib/test/test_asyncgen.py @@ -1058,8 +1058,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(): @@ -1069,7 +1068,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) |