asyncio.Future.done()

done() Return True if the future is done. Done means either that a result / exception are available, or that the future was cancelled.

asyncio.Future.cancelled()

cancelled() Return True if the future was cancelled.

asyncio.Future.cancel()

cancel() Cancel the future and schedule callbacks. If the future is already done or cancelled, return False. Otherwise, change the future’s state to cancelled, schedule the callbacks and return True.

asyncio.Future.add_done_callback()

add_done_callback(fn) Add a callback to be run when the future becomes done. The callback is called with a single argument - the future object. If the future is already done when this is called, the callback is scheduled with call_soon(). Use functools.partial to pass parameters to the callback. For example, fut.add_done_callback(functools.partial(print, "Future:", flush=True)) will call print("Future:", fut, flush=True).

asyncio.Future

class asyncio.Future(*, loop=None) This class is almost compatible with concurrent.futures.Future. Differences: result() and exception() do not take a timeout argument and raise an exception when the future isn’t done yet. Callbacks registered with add_done_callback() are always called via the event loop’s call_soon_threadsafe(). This class is not compatible with the wait() and as_completed() functions in the concurrent.futures package. This class is not thread safe. cancel() Cancel th

asyncio.Event.wait()

coroutine wait() Block until the internal flag is true. If the internal flag is true on entry, return True immediately. Otherwise, block until another coroutine calls set() to set the flag to true, then return True. This method is a coroutine.

asyncio.Event.set()

set() Set the internal flag to true. All coroutines waiting for it to become true are awakened. Coroutine that call wait() once the flag is true will not block at all.

asyncio.Event.is_set()

is_set() Return True if and only if the internal flag is true.

asyncio.Event.clear()

clear() Reset the internal flag to false. Subsequently, coroutines calling wait() will block until set() is called to set the internal flag to true again.

asyncio.Event

class asyncio.Event(*, loop=None) An Event implementation, asynchronous equivalent to threading.Event. Class implementing event objects. An event manages a flag that can be set to true with the set() method and reset to false with the clear() method. The wait() method blocks until the flag is true. The flag is initially false. This class is not thread safe. clear() Reset the internal flag to false. Subsequently, coroutines calling wait() will block until set() is called to set the interna