asyncx.dispatch_coroutine
- async asyncx.dispatch_coroutine(coro, target_loop)[source]
Execute the specified coroutine on the specified event loop.
Example
>>> async def foo() -> None: ... return threading.get_ident() ... >>> current, dispatched = await asyncio.gather( ... foo(), ... asyncx.dispatch_coroutine(foo(), other_loop), ... ) >>> current != dispatched True
- Parameters
coro (Coroutine[Any, Any, asyncx._types.TReturn]) – A coroutine to be dispatched.
target_loop (asyncio.events.AbstractEventLoop) – An event loop to execute the
coro.
- Return type
asyncx._types.TReturn