@@ -390,6 +390,7 @@ async def make_list(a: list[int]) -> list[int]:
390390async def spill() -> list[int]:
391391 a: list[int] = []
392392 for i in range(5):
393+ await asyncio.sleep(0.0001)
393394 a = (await make_list(a + [1])) + a + (await make_list(a + [2]))
394395 return a
395396
@@ -398,17 +399,22 @@ async def bar(n: int) -> None:
398399 await spill()
399400
400401def test_spilled() -> None:
401- assert_no_leaks(lambda: bar(100 ), 2)
402+ assert_no_leaks(lambda: bar(40 ), 2)
402403
403404async def raise_deep(n: int) -> str:
404405 if n == 0:
406+ await asyncio.sleep(0.0001)
405407 raise TypeError(str(n))
406408 else:
409+ if n == 2:
410+ await asyncio.sleep(0.0001)
407411 return await raise_deep(n - 1)
408412
409413async def maybe_raise(n: int) -> str:
410414 if n % 3 == 0:
411- await raise_deep(10)
415+ await raise_deep(5)
416+ elif n % 29 == 0:
417+ await asyncio.sleep(0.0001)
412418 return str(n)
413419
414420async def exc(n: int) -> list[str]:
@@ -421,7 +427,7 @@ async def exc(n: int) -> list[str]:
421427 return a
422428
423429def test_exception() -> None:
424- assert_no_leaks(lambda: exc(100 ), 2)
430+ assert_no_leaks(lambda: exc(50 ), 2)
425431
426432class C:
427433 def __init__(self, s: str) -> None:
@@ -431,7 +437,9 @@ async def id(c: C) -> C:
431437 return c
432438
433439async def stolen_helper(c: C, s: str) -> str:
440+ await asyncio.sleep(0.0001)
434441 (await id(c)).s = await concat_one(s)
442+ await asyncio.sleep(0.0001)
435443 return c.s
436444
437445async def stolen(n: int) -> int:
@@ -442,7 +450,8 @@ async def stolen(n: int) -> int:
442450 return n
443451
444452def test_stolen() -> None:
445- assert_no_leaks(lambda: stolen(1000 ), 2)
453+ assert_no_leaks(lambda: stolen(100 ), 2)
446454
447455[file asyncio/__init__.pyi]
448456def run(x: object) -> object: ...
457+ async def sleep(t: float) -> None: ...
0 commit comments