Skip to content

Commit 45d9963

Browse files
kumaraditya303miss-islington
authored andcommitted
pythonGH-109067: fix randomly failing test_async_gen_asyncio_gc_aclose_09 test (pythonGH-109142)
Use `asyncio.sleep(0)` instead of short sleeps. (cherry picked from commit ccd4862) Co-authored-by: Kumar Aditya <[email protected]>
1 parent a1ba0e5 commit 45d9963

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Lib/test/test_asyncgen.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,8 +1057,7 @@ async def gen():
10571057
while True:
10581058
yield 1
10591059
finally:
1060-
await asyncio.sleep(0.01)
1061-
await asyncio.sleep(0.01)
1060+
await asyncio.sleep(0)
10621061
DONE = 1
10631062

10641063
async def run():
@@ -1068,7 +1067,10 @@ async def run():
10681067
del g
10691068
gc_collect() # For PyPy or other GCs.
10701069

1071-
await asyncio.sleep(0.1)
1070+
# Starts running the aclose task
1071+
await asyncio.sleep(0)
1072+
# For asyncio.sleep(0) in finally block
1073+
await asyncio.sleep(0)
10721074

10731075
self.loop.run_until_complete(run())
10741076
self.assertEqual(DONE, 1)

0 commit comments

Comments
 (0)