Runtime Types

types.AsyncGeneratorType — runtime type

Identifies objects created by async generator functions, which combine async def and yield. Use async for or anext() rather than ordinary next(). Exhaustion uses StopAsyncIteration; aclose() permits asynchronous cleanup. It is not the same as a native coroutine.

Formal Syntax & Structure

python syntaxpython
types.AsyncGeneratorType

Return Value

type

The class object types.AsyncGeneratorType; this reference documents the class identity, not a universal constructor signature.

Working Example

Example Snippetpython
import types, asyncioasync def values(): yield 4async def main():    gen=values()    print(isinstance(gen,types.AsyncGeneratorType))    print([x async for x in gen])asyncio.run(main())
Python Reference