codejump

FastAPI Internals & Edge Cases — Series 2

Preview — 3 of 10 questions

A function-scoped yield dependency needs a request-scoped yield sub-dependency. Is this scope graph valid?

AOnly if response_model is disabled
BYes, the child can outlive its function-scoped consumer
CNo, every child must close before the parent
DOnly if the endpoint is synchronous

An endpoint returns a StreamingResponse that reads a database cursor supplied by a yield dependency. Which teardown timing protects the stream?

ARequest-scoped teardown after the response is sent
BFunction-scoped teardown before the response is sent
CApplication startup teardown
DTeardown as soon as the endpoint returns the iterator

A route uses responses={404: {"model": ErrorBody}}. What does that declaration itself do?

AMake every response a 404
BValidate every runtime 404 body automatically
CRegister a 404 exception handler globally
DDocument the extra response shape, without making the handler return 404

Sign up free to play

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