aioplus.acycle

aioplus.acycle(aiterable, /)

Make an iterator returning elements from the aiterable and saving a copy of each.

Parameters:

aiterable (AsyncIterable of T) – An asynchronous iterable of elements to be cycled.

Returns:

An asynchronous iterable yielding elements from the input iterable.

Return type:

AsyncIterable of T

Examples

>>> aiterable = arange(23)
>>> [num async for num in acycle(aiterable)]
[0, 1, ..., 22, 23, 0, 1, ..., 22, 23, ...]

Notes

  • Entire iterable is buffered in memory before yielding results;

  • Yields control to the event loop before producing each value.