Created
April 30, 2015 12:25
-
-
Save mgmarino/16a7b194e331c0550dfb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import signal | |
import time | |
_should_quit = False | |
def should_quit(): | |
return _should_quit | |
def handler(signum, frame): | |
global _should_quit | |
print 'Signal handler called with signal', signum | |
_should_quit = True | |
signal.signal(signal.SIGINT, handler) | |
# Set the signal handl | |
while 1: | |
for i in range(5): | |
time.sleep(1) | |
if should_quit(): break | |
print "Now I'm being called" | |
if should_quit(): break | |
print "I was nicely ended" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment