All quizzesHard
Lifecycle & Production Behavior
Preview — 3 of 10 questions
An async def endpoint calls a synchronous, blocking HTTP client directly. What is the main risk?
AFastAPI converts the call to async automatically
BIt can block the event loop while that call runs
CThe endpoint always returns HTTP 422
DIt makes the response model optional
What does use_cache=False change for a dependency declaration?
AIt disables response caching for every endpoint
BIt asks FastAPI to call that dependency again instead of reusing a result cached in the request
CIt persists the dependency result across requests
DIt turns the dependency into middleware
Where should app-wide resources such as a shared async client be created and closed in a modern FastAPI app?
AIn every route call
BIn the module's __del__
CIn a lifespan context manager around app startup and shutdown
DIn a Pydantic field validator
Sign up free to play
Answer all 10 questions (7 more), see explanations for every answer, and track your score.