Skip to content

Commit 1336ca5

Browse files
committed
Fix syntax_async
1 parent edf5995 commit 1336ca5

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

extra_tests/snippets/syntax_async.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,26 @@ async def __anext__(self):
3333
return value
3434

3535

36+
if sys.platform.startswith("win"):
37+
SLEEP_UNIT = 0.5
38+
else:
39+
SLEEP_UNIT = 0.1
40+
3641
async def a(s, m):
3742
async with ContextManager() as b:
3843
print(f"val = {b}")
3944
await asyncio.sleep(s)
4045
async for i in AIterWrap(range(0, 2)):
4146
print(i)
4247
ls.append(m)
43-
await asyncio.sleep(0.2)
48+
await asyncio.sleep(SLEEP_UNIT)
4449

4550

4651

4752
async def main():
4853
tasks = [
4954
asyncio.create_task(c)
50-
for c in [a(0.0, "hello1"), a(0.2, "hello2"), a(0.4, "hello3"), a(0.6, "hello4")]
55+
for c in [a(SLEEP_UNIT * 0, "hello1"), a(SLEEP_UNIT * 1, "hello2"), a(SLEEP_UNIT * 2, "hello3"), a(SLEEP_UNIT * 3, "hello4")]
5156
]
5257
await asyncio.wait(tasks)
5358

0 commit comments

Comments
 (0)