NANDHOO
.
Learning Paths
Dashboard
Sign In
Home
Dashboard
FastAPI Framework Engineering
Real-Time Systems & Background Tasks
Quiz
Chapter Quiz: Real-Time Systems & Background Tasks
Mastery Assessment: Background & WebSockets
Complete this assessment with 100% score to master this chapter.
01
When does a function added via `BackgroundTasks.add_task()` execute?
Immediately before the route starts.
Exactly when the CPU is idle.
After the HTTP response has been sent to the client.
Only on Sundays.
02
What is the main advantage of WebSockets over standard HTTP for real-time apps?
They are more secure.
They provide a full-duplex, persistent connection with lower overhead than repeated HTTP requests.
They can only send binary data.
They don't require a server.
03
How do you handle a client disconnecting from a WebSocket in FastAPI?
The server automatically crashes.
Catch the `WebSocketDisconnect` exception.
The function returns `None`.
You must ping the client every second.
Submit Answers
Back to Lesson
Next Chapter