Skip to content

Instantly share code, notes, and snippets.

@mreiferson
Last active December 18, 2015 01:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mreiferson/5701329 to your computer and use it in GitHub Desktop.
Save mreiferson/5701329 to your computer and use it in GitHub Desktop.
import functools
import sys
import logging
def exit_on_exception(method):
@functools.wraps(method)
def wrapped(*args, **kwargs):
try:
return method(*args, **kwargs)
except MyException:
logging.exception("crazy shit happened... exiting")
sys.exit(1)
return wrapped
@exit_on_exception
def message_handler(nsq_msg):
return do_some_crazy_mongo_shit_that_throws_exceptions(nsq_msg.body)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment