Skip to content

Commit 8c4d328

Browse files
committed
asyncio.run introduced some breakage
1 parent a3c1816 commit 8c4d328

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/trio/_core/_tests/test_guest_mode.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,8 +440,9 @@ def aiotrio_run(
440440
pass_not_threadsafe: bool = True,
441441
**start_guest_run_kwargs: Any,
442442
) -> T:
443+
loop = asyncio.get_running_loop()
444+
443445
async def aio_main() -> T:
444-
loop = asyncio.get_running_loop()
445446
trio_done_fut: asyncio.Future[Outcome[T]] = loop.create_future()
446447

447448
def trio_done_callback(main_outcome: Outcome[T]) -> None:
@@ -460,7 +461,12 @@ def trio_done_callback(main_outcome: Outcome[T]) -> None:
460461

461462
return (await trio_done_fut).unwrap()
462463

463-
return asyncio.run(aio_main())
464+
try:
465+
# can't use asyncio.run because that fails on Windows (3.8, x64, with
466+
# Komodia LSP)
467+
return loop.run_until_complete(aio_main())
468+
finally:
469+
loop.close()
464470

465471

466472
def test_guest_mode_on_asyncio() -> None:

0 commit comments

Comments
 (0)