ID EN
Typing

AsyncGenerator

Python 3.11

Deprecated alias to collections.abc.AsyncGenerator.

Syntax

PYTHON
class typing.AsyncGenerator(AsyncIterator[YieldType], Generic[YieldType, SendType])

Examples

Example 1
PYTHON
async def echo_round() -> AsyncGenerator[int, float]:
    sent = yield 0
    while sent >= 0.0:
        rounded = await round(sent)
        sent = yield rounded
Example 2
PYTHON
async def infinite_stream(start: int) -> AsyncGenerator[int, None]:
    while True:
        yield start
        start = await increment(start)
Example 3
PYTHON
async def infinite_stream(start: int) -> AsyncIterator[int]:
    while True:
        yield start
        start = await increment(start)

See Also

collections.abc.AsyncGenerator Generator collections.abc.AsyncGenerator Generic Alias Type