SoloMedium5m
The Graceful Shutdown Trap
Deployment incident — 15% 502 spike during rollout
DevOps: New pods healthy, but old pods killed mid-request when Kubernetes sent SIGTERM. Load balancer routed to dead pods — in-flight connections severed.
The trap: No signal handler — Python exits instantly, dropping every active thread.
Your task
Implement `register_graceful_shutdown()`, `handle_sigterm()`, and fix `start_server()` in `server.py`: stop accepting traffic on SIGTERM, drain in-flight requests, then exit cleanly.
Book: write the handler · Prod: catch SIGTERM or sever 500 TCP connections on every deploy.
Skills you'll prove
pythonkuberneteslinux-signalssigtermgraceful-shutdownconnection-draininginfrastructurebook-vs-prod