euporie.core.convert.datum.run_coro_sync

euporie.core.convert.datum.run_coro_sync(coro: Coroutine[Any, Any, T], loop: asyncio.AbstractEventLoop | None = None) T

Run a coroutine synchronously from a sync context.

In Pyodide, where the main loop is already running, this yields control back to the event loop repeatedly until the coroutine completes.

In normal Python with a background loop, this uses run_coroutine_threadsafe.

Parameters:
  • coro – The coroutine to run

  • loop – The event loop to run on (if None, uses current running loop or raises)

Returns:

The result of the coroutine

Raises:

RuntimeError – If no loop is provided and none is running