Monday 11 December 2023

How to convert AsyncIterable to asyncio Task

I am using Python 3.11.5 with the below code:

import asyncio
from collections.abc import AsyncIterable


async def iterable() -> AsyncIterable[int]:
    yield 1
    yield 2
    yield 3


# How can one get this async iterable to work with asyncio.gather?
asyncio.gather(iterable())

How can one get an AsyncIterable to work with asyncio tasks (e.g. for use with asyncio.gather)?



from How to convert AsyncIterable to asyncio Task

No comments:

Post a Comment