Skip to content

Commit 50617c8

Browse files
committed
Fix flaky test
1 parent acfe159 commit 50617c8

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

tests/interop/test_calls.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import pytest
22
import asyncio
33
import trio
4+
import trio.testing
45
import sniffio
56
from trio_asyncio import aio_as_trio, trio_as_aio, run_aio_generator
67
from tests import aiotest
@@ -331,16 +332,13 @@ async def dly_asyncio(hold, seen):
331332
seen.flag |= 1
332333
await hold.wait()
333334

334-
async def cancel_soon(nursery):
335-
await trio.sleep(0.01)
336-
nursery.cancel_scope.cancel()
337-
338335
hold = asyncio.Event()
339336
seen = Seen()
340337

341338
async with trio.open_nursery() as nursery:
342339
nursery.start_soon(async_gen_to_list, run_aio_generator(loop, dly_asyncio(hold, seen)))
343-
nursery.start_soon(cancel_soon, nursery)
340+
await trio.testing.wait_all_tasks_blocked()
341+
nursery.cancel_scope.cancel()
344342
assert nursery.cancel_scope.cancel_called
345343
assert seen.flag == 1
346344

0 commit comments

Comments
 (0)