signal
Handle OS signals like Ctrl+C (SIGINT) or SIGTERM for graceful shutdown.
Intermediate
import signal
signal.signal(signal.SIGTERM, lambda *_: shutdown())
Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.
Discussion (0)
Sign in or join free to ask questions and discuss this topic.