Skip to content

Instantly share code, notes, and snippets.

@rectalogic
Created December 11, 2015 19:57
Show Gist options
  • Save rectalogic/f987b02624c40da06c2b to your computer and use it in GitHub Desktop.
Save rectalogic/f987b02624c40da06c2b to your computer and use it in GitHub Desktop.
import signal
import Queue
def handler(signum, frame):
q.put(None)
signal.signal(signal.SIGTERM, handler)
signal.signal(signal.SIGINT, handler)
q = Queue.Queue()
while True:
try:
v = q.get(timeout=100000)
if v is None:
print "Got None"
break
except Queue.Empty:
print "Empty"
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment