How to make a multi-thread python program response to Ctrl+C key event?
Edit: The code is like this:
import threading current = 0 c
thread1 = threading.Thread(target=your_procedure, args = (arg_1, arg_2)) try: thread1.setDaemon(True) # very important thread1.start() except (KeyboardInterrupt, SystemExit): cleanup_stop_thread() sys.exit()
When you want to kill the thread just use:
thread1.join(0)