m7mdharon

Python Script for Handling Interrupt

Nov 20th, 2025
7
0
Never
Not a member of gistpad yet? Sign Up, it unlocks many cool features!
Python 1.96 KB | Source Code | 0 0
  1. #!/usr/bin/python3
  2. # -*- coding: utf-8 -*-
  3.  
  4. import os
  5. import sys
  6.  
  7. from knock.knockpy import main
  8.  
  9. if __name__ == "__main__":
  10. try:
  11. main()
  12. except KeyboardInterrupt:
  13. print("\nInterrupted")
  14. try:
  15. sys.exit(0)
  16. except SystemExit:
  17. os._exit(0)
RAW Gist Data Copied