From fbb5e78176ecc6f9ba4c27e50b5a67d3b9d5d119 Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Fri, 24 Feb 2023 15:44:22 +0900 Subject: [PATCH 1/2] double windows sleep for syntax_async --- extra_tests/snippets/syntax_async.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra_tests/snippets/syntax_async.py b/extra_tests/snippets/syntax_async.py index a817a61a3f..064dadc7f4 100644 --- a/extra_tests/snippets/syntax_async.py +++ b/extra_tests/snippets/syntax_async.py @@ -34,7 +34,7 @@ async def __anext__(self): if sys.platform.startswith("win"): - SLEEP_UNIT = 0.5 + SLEEP_UNIT = 1.0 else: SLEEP_UNIT = 0.1 From ae3de43a62036e84dbb304f362cbed6303044020 Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Fri, 24 Feb 2023 21:44:10 +0900 Subject: [PATCH 2/2] retry 10times in windows --- extra_tests/snippets/syntax_async.py | 33 ++++++++++++++++++---------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/extra_tests/snippets/syntax_async.py b/extra_tests/snippets/syntax_async.py index 064dadc7f4..011182cce7 100644 --- a/extra_tests/snippets/syntax_async.py +++ b/extra_tests/snippets/syntax_async.py @@ -32,11 +32,7 @@ async def __anext__(self): raise StopAsyncIteration return value - -if sys.platform.startswith("win"): - SLEEP_UNIT = 1.0 -else: - SLEEP_UNIT = 0.1 +SLEEP_UNIT = 0.1 async def a(s, m): async with ContextManager() as b: @@ -48,19 +44,14 @@ async def a(s, m): await asyncio.sleep(SLEEP_UNIT) - -async def main(): +async def run(): tasks = [ asyncio.create_task(c) for c in [a(SLEEP_UNIT * 0, "hello1"), a(SLEEP_UNIT * 1, "hello2"), a(SLEEP_UNIT * 2, "hello3"), a(SLEEP_UNIT * 3, "hello4")] ] await asyncio.wait(tasks) - -ls = [] -asyncio.run(main(), debug=True) - -assert ls == [ +expected = [ 1, 3, 1, @@ -78,6 +69,24 @@ async def main(): "hello3", "hello4", ] +ls = [] + +def test(): + global SLEEP_UNIT + if sys.platform.startswith("win"): + SLEEP_UNIT *= 2 + ls.clear() + asyncio.run(run(), debug=True) + assert ls == expected + + +for i in reversed(range(10)): + try: + test() + break + except AssertionError: + if i == 0: + raise if sys.version_info < (3, 11, 0):