Wraps an iterable (sync or async) into an async generator.
(
it: Iterable[_T] | AsyncIterator[_T],
)
| 11 | |
| 12 | |
| 13 | async def as_async_generator( |
| 14 | it: Iterable[_T] | AsyncIterator[_T], |
| 15 | ) -> AsyncGenerator[_T]: |
| 16 | """Wraps an iterable (sync or async) into an async generator.""" |
| 17 | if isinstance(it, AsyncIterator): |
| 18 | async for r in it: |
| 19 | yield r |
| 20 | else: |
| 21 | for r in it: |
| 22 | yield r |
no outgoing calls