Python 3.5+collectionsterm
collections.abc.Awaitable
collections.abc — protocols
The protocol for objects usable with await (has __await__).
Syntax
isinstance(obj, collections.abc.Awaitable)
Calling an async function starts nothing; it just builds a coroutine object, and dropping it unawaited triggers the coroutine was never awaited warning, which is why the example closes it. A coroutine can be awaited only once — a second await on the same object raises RuntimeError. Awaitable is the wider notion: Tasks and Futures qualify too, so it is the better annotation when you accept anything that can be awaited.
Examples
import collections.abc as abc
async def f(): pass
c = f()
print(isinstance(c, abc.Awaitable)) # → True
c.close()
See also
Open in the full glossarydocs.python.orgReport an inaccuracy