What is lifespan in FastAPI?
Lifespan hooks run application startup and shutdown logic such as opening shared clients or closing resources cleanly.
- Startup for shared setup
- Shutdown for cleanup
- Useful for pools and model loading
What is lifespan in FastAPI?