euporie.core.kernel.base.run_coro_async

euporie.core.kernel.base.run_coro_async(coro: Coroutine[Any, Any, T], loop: asyncio.AbstractEventLoop, *, cancel_previous: bool = False, previous_tasks: dict[str, asyncio.Future] | None = None, callback: Callable[[T], None] | None = None) asyncio.Future[T]

Schedule a coroutine on a loop from any context, returning a Future.

Handles both normal Python (background thread loop) and Pyodide (main loop) scheduling transparently.

Parameters:
  • coro – The coroutine to schedule

  • loop – The event loop to run on

  • cancel_previous – If True, cancel any previous task for this coroutine

  • previous_tasks – Dict to track and optionally cancel previous tasks by name

  • callback – Optional callback to run when the coroutine completes

Returns:

A Future that will contain the result