KeyboardInterrupt (script stopped with Ctrl+C) / ^C traceback
The script was interrupted (Ctrl+C, SIGINT, or a container stop), producing a KeyboardInterrupt traceback.
Meaning
Not a bug in itself — but long-running scripts should catch it to clean up (close files, flush data) and exit gracefully. Docker sends SIGTERM first, which Python doesn’t handle by default.
Common causes
- Manual Ctrl+C
- Process manager or container stop
- Infinite loop that had to be interrupted
⚡ Quick fix
- Wrap the main loop in try/except KeyboardInterrupt to clean up
- Handle SIGTERM with the signal module in containers
- Fix infinite loops if the interrupt was needed
Detailed fix by platform
Python
- python
import signal, sys signal.signal(signal.SIGTERM, lambda *_: sys.exit(0))
How to diagnose
- Trigger — Who interrupted it?
- Cleanup — Was data left half-written?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in Python
Other ways to find it
Where this error sits
Origin: Application & API. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 13 Oct 2026