Handling Signals in Python Threads
问题 I have a threaded application written in Python, and whenever an interrupt is received via Ctrl + C or sometimes with kill, the application will hang. A stack trace is presented from one thread, but the application remains in the foreground, and I usually have to background it with Ctrl + Z then attempt to kill it. What is the proper way of handling signals and keyboard interrupts inside of a threaded application? 回答1: If you set newthread.daemon = True before starting each thread, the