Python 3.5+collectionsterm
collections.abc.AsyncIterable
collections.abc — protocols
The protocol for objects usable in async for (has __aiter__).
Syntax
isinstance(obj, collections.abc.AsyncIterable)
The check only looks for __aiter__ and promises nothing beyond that: iteration can still blow up if whatever __aiter__ returns lacks __anext__ — that stricter guarantee belongs to AsyncIterator. Also keep in mind an async iterable is not a regular Iterable: for, list() and itertools will not touch it, you need async for or a comprehension like [x async for x in it].
Examples
import collections.abc as abc
async def ag():
yield 1
print(isinstance(ag(), abc.AsyncIterable)) # → True
See also
Open in the full glossarydocs.python.orgReport an inaccuracy