codejump

Session & Production Behavior

Preview — 3 of 10 questions

An async def FastAPI route calls a blocking synchronous ORM query directly. What is the performance risk?

AIt can block the event loop while the query waits
BFastAPI automatically converts the query to async SQL
CThe database commits twice
DOpenAPI hides the route

Two concurrent asyncio tasks share one AsyncSession instance. Why is that unsafe?

AIt makes both tasks read-only automatically
BAsyncSession is mutable transaction state intended for one task at a time
CSQLAlchemy creates a new Session for each statement
DThe engine becomes a response model

A handler commits a row, then a later related write fails. Why is this transaction boundary wrong for one logical operation?

ACommit only flushes the row temporarily
BFastAPI reruns the whole request automatically
CThe first commit cannot be rolled back with the later failure
DBoth writes are always rolled back together

Sign up free to play

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