diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2023-09-12 13:56:02 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-12 13:56:02 (GMT) |
commit | c76f4b97dcede6790a0e43d7d36179a298bbf0a6 (patch) | |
tree | 22924bf2ab2b238fcf159fdf42d4913524c600f6 /Lib/test | |
parent | ca848bbf78cf82447cc5c2fe6822c82f6f9e59c4 (diff) | |
download | cpython-c76f4b97dcede6790a0e43d7d36179a298bbf0a6.zip cpython-c76f4b97dcede6790a0e43d7d36179a298bbf0a6.tar.gz cpython-c76f4b97dcede6790a0e43d7d36179a298bbf0a6.tar.bz2 |
[3.12] GH-109067: fix randomly failing `test_async_gen_asyncio_gc_aclose_09` test (GH-109142) (#109149)
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>
Diffstat (limited to 'Lib/test')
-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 09e4010..9a93437 100644 --- a/Lib/test/test_asyncgen.py +++ b/Lib/test/test_asyncgen.py @@ -1057,8 +1057,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(): @@ -1068,7 +1067,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) |