View source on GitHub |
Runs asyncio coroutines in a thread, exposes the results as duet futures.
cirq_google.engine.asyncio_executor.AsyncioExecutor() -> None
This lets us bridge between an asyncio event loop (which is what async grpc code uses) and duet (which is what cirq uses for asynchrony).
Methods
instance
@classmethod
instance() -> 'AsyncioExecutor'
Returns a singleton AsyncioExecutor shared globally.
submit
submit(
func: Callable[P, Awaitable[R]], *args, **kwargs
) -> duet.AwaitableFuture[R]
Dispatch the given function to be run in an asyncio coroutine.
Args | |
---|---|
func
|
asyncio function which will be run in a separate thread. Will be called with *args and **kw and should return an asyncio awaitable. |
*args
|
Positional args to pass to func. |
**kwargs
|
Keyword args to pass to func. |