mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
[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 ccd48623d4)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
This commit is contained in:
parent
c1a2ef5efc
commit
6b2f44ea78
1 changed files with 5 additions and 3 deletions
|
|
@ -1037,8 +1037,7 @@ async def gen():
|
||||||
while True:
|
while True:
|
||||||
yield 1
|
yield 1
|
||||||
finally:
|
finally:
|
||||||
await asyncio.sleep(0.01)
|
await asyncio.sleep(0)
|
||||||
await asyncio.sleep(0.01)
|
|
||||||
DONE = 1
|
DONE = 1
|
||||||
|
|
||||||
async def run():
|
async def run():
|
||||||
|
|
@ -1048,7 +1047,10 @@ async def run():
|
||||||
del g
|
del g
|
||||||
gc_collect() # For PyPy or other GCs.
|
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.loop.run_until_complete(run())
|
||||||
self.assertEqual(DONE, 1)
|
self.assertEqual(DONE, 1)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue