Skip to content

Commit ccd4862

Browse files
pythonGH-109067: fix randomly failing test_async_gen_asyncio_gc_aclose_09 test (python#109142)
Use `asyncio.sleep(0)` instead of short sleeps.
1 parent 52beebc commit ccd4862

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
@@ -1058,8 +1058,7 @@ async def gen():
10581058
while True:
10591059
yield 1
10601060
finally:
1061-
await asyncio.sleep(0.01)
1062-
await asyncio.sleep(0.01)
1061+
await asyncio.sleep(0)
10631062
DONE = 1
10641063

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

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

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

0 commit comments

Comments
 (0)