codejump

FastAPI Internals & Edge Cases

Preview — 3 of 10 questions

A request-scoped yield dependency depends on another yield dependency. Which scope may the sub-dependency have?

AEither scope, with identical cleanup timing
BNo scope because nesting is forbidden
COnly request scope
DOnly function scope

Yield dependency outer uses a resource from yield dependency inner, and both have teardown code. What is the normal cleanup order?

ACleanup order is random
Bouter closes before inner
Cinner closes before outer
DBoth close before the route runs

A yield dependency catches an exception from the route but does not re-raise it. What is the debugging risk?

AFastAPI no longer sees that caught exception
BFastAPI retries the route automatically
CThe exception is always converted to a 422
DThe dependency runs its setup twice

Sign up free to play

Answer all 10 questions (7 more), see explanations for every answer, and track your score.