Python - Can't kill main thread with KeyboardInterrupt Python - Can't kill main thread with KeyboardInterrupt multithreading multithreading

Python - Can't kill main thread with KeyboardInterrupt


You made your threads daemons already, but you need to keep your main thread alive while daemon threads are there, there's how to do that: Cannot kill Python script with Ctrl-C


When you create the threads add them to a list of running threads and when dealing with ctrl-C send a kill signal to each thread on the list. That way you are actively cleaning up rather than relying on it being done for you.