aioplus.anextify¶
- aioplus.anextify(iterable, /, *, executor=None)¶
Make an iterable asynchronous.
- Parameters:
iterable (Iterable[T]) – An iterable to be wrapped for asynchronous execution.
executor (ThreadPoolExecutor, optional) – An optional
concurrent.futures.ThreadPoolExecutorto run the function in. IfNone, the default executor is used.
- Returns:
An asynchronous iterable that, when awaited, calls
object.__next__()in the executor.- Return type:
AsyncIterable[T]
Examples
>>> iterable = [0, 1, 2, 3, 4, 5] >>> aiterable = anextify(iterable) >>> [num async for num in aiterable] [0, 1, 2, 3, 4, 5]
See also