So let's say I have this code:
import signal from time import sleep def signalHandler(sig, frame): print "signalHandler" while True: sleep(1)
As you can see from the comment, if the print statement is uncommented, the code works fine, and the signal handler will catch any subsequent CTRL-C presses, as it should be. However, if you leave a comment, another signal will never be caught.
Why is this? I assume that consecutive sleep calls are stretched together and control never returns to the python to catch the signal. What it would have to do for a press statement. Can anyone shed some light on this?
source share