Skip to content

Commit

Permalink
try asyncio.run again
Browse files Browse the repository at this point in the history
  • Loading branch information
graingert committed Oct 28, 2024
1 parent 28957e0 commit 9f1823a
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/trio/_core/_tests/test_guest_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,9 +438,9 @@ def aiotrio_run(
pass_not_threadsafe: bool = True,
**start_guest_run_kwargs: Any,
) -> T:
loop = asyncio.new_event_loop()

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

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

return (await trio_done_fut).unwrap()

try:
# can't use asyncio.run because that fails on Windows (3.8, x64, with
# Komodia LSP)
return loop.run_until_complete(aio_main())
finally:
loop.close()
return asyncio.run(aio_main())


def test_guest_mode_on_asyncio() -> None:
Expand Down

0 comments on commit 9f1823a

Please sign in to comment.