The documentation 6.2.9.4. "Asynchronous generator-iterator methods" is phrased really ambiguously. To make matters worse, typing.AsyncGenerator
is not specified fully correctly.
Here, I attempt to more clearly capture the actual interface contract, based on what I've read and observed. See also PEP 492 -- Coroutines with async and await syntax and PEP 525 -- Asynchronous Generators.
This might be useful to implement lower-level behaviors than you can with async for
, like sending values into the generator function.
TSend = TypeVar('TSend', contravariant=True)