Skip to content

Instantly share code, notes, and snippets.

@rectalogic
Created December 11, 2015 19:40
Show Gist options
  • Save rectalogic/bd4820a4cf0e93cca801 to your computer and use it in GitHub Desktop.
Save rectalogic/bd4820a4cf0e93cca801 to your computer and use it in GitHub Desktop.
import signal
import Queue
def handler(signum, frame):
global shutdown
# Don't log here, not reentrant
shutdown = True
signal.signal(signal.SIGTERM, handler)
signal.signal(signal.SIGINT, handler)
q = Queue.Queue()
while True:
try:
q.get(timeout=100000)
except Queue.Empty:
print "Empty"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment