KeyboardInterrupt (script stopped with Ctrl+C) / ^C traceback
The script was interrupted (Ctrl+C, SIGINT, or a container stop), producing a KeyboardInterrupt traceback.
Seen on:
Python
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 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.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026