Last active
December 18, 2015 01:08
-
-
Save mreiferson/5701329 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 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