Skip to content

Commit

Permalink
asyncio.run introduced some breakage
Browse files Browse the repository at this point in the history
  • Loading branch information
graingert committed Oct 18, 2024
1 parent a3c1816 commit fc1f5bb
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/trio/_core/_tests/test_guest_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,8 +440,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 @@ -460,7 +461,12 @@ def trio_done_callback(main_outcome: Outcome[T]) -> None:

return (await trio_done_fut).unwrap()

return asyncio.run(aio_main())
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()


def test_guest_mode_on_asyncio() -> None:
Expand Down

0 comments on commit fc1f5bb

Please sign in to comment.