cirq_google.engine.asyncio_executor.AsyncioExecutor

Runs asyncio coroutines in a thread, exposes the results as duet futures.

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

View source

Returns a singleton AsyncioExecutor shared globally.

submit

View source

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.