StopAsyncIteration

Built-in ExceptionPython 2.0+Expert

Raised by __anext__() to signal an async iterator is exhausted

Quick Info

Documentation
Official Docs
Python Version
2.0+

Learn by Difficulty

Quick Example

python
# Triggering and catching StopAsyncIteration
try:
    raise StopAsyncIteration("async iteration done")
except StopAsyncIteration as e:
    print(f"Caught StopAsyncIteration: {e}")
    print(f"Type: {type(e).__name__}")

StopAsyncIteration is raised when raised by __anext__() to signal an async iterator is exhausted. Always catch specific exceptions rather than bare except clauses.

Try in Playground

Tags

exceptionerror-handlingcore