FastAPI Lifespan: The Right Way to Share Resources Across Requests
FastAPI's lifespan context manager replaces deprecated on_event handlers for startup/shutdown. Learn how to share a single pooled httpx.AsyncClient across requests, wire it through dependency injection, and avoid common testing pitfalls.