Skip to content

Instantly share code, notes, and snippets.

@mgmarino
Created April 30, 2015 12:25
Show Gist options
  • Save mgmarino/16a7b194e331c0550dfb to your computer and use it in GitHub Desktop.
Save mgmarino/16a7b194e331c0550dfb to your computer and use it in GitHub Desktop.
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