FastAPI · Concept
Lifespan events
FastAPI lifespan handlers run setup once before requests and cleanup once when the application shuts down. Define them with an async context manager and pass it to FastAPI.
Last updated
Syntax
FastAPI(lifespan=lifespan)In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.
SubscribeRelated
startupshutdownTestClientSub Applications - Mountson_event