Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9f1823a

Browse files
committed
try asyncio.run again
1 parent 28957e0 commit 9f1823a

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/trio/_core/_tests/test_guest_mode.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -438,9 +438,9 @@ def aiotrio_run(
438438
pass_not_threadsafe: bool = True,
439439
**start_guest_run_kwargs: Any,
440440
) -> T:
441-
loop = asyncio.new_event_loop()
442441

443442
async def aio_main() -> T:
443+
loop = asyncio.get_running_loop()
444444
trio_done_fut: asyncio.Future[Outcome[T]] = loop.create_future()
445445

446446
def trio_done_callback(main_outcome: Outcome[T]) -> None:
@@ -459,12 +459,7 @@ def trio_done_callback(main_outcome: Outcome[T]) -> None:
459459

460460
return (await trio_done_fut).unwrap()
461461

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

469464

470465
def test_guest_mode_on_asyncio() -> None:

0 commit comments

Comments
 (0)