Skip to content

Glossary: Building APIs with FastAPI

asynccontextmanager

A decorator from `contextlib` that turns an async generator into a context manager. FastAPI uses one for the lifespan function, which sets up before `yield` and cleans up after.

Where the book teaches it

Related terms

Lifespanyield dependency