Created
August 30, 2012 00:40
-
-
Save skyler/3521065 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
from gearman import GearmanWorker | |
from traceback import format_exception, print_exception | |
from StringIO import StringIO | |
import logging | |
class ExceptionalGearmanWorker(GearmanWorker): | |
def on_job_exception(self, current_job, exception_tuple): | |
""" Override the default on_job_exception handler to log an error | |
to the console. | |
""" | |
sbuffer = StringIO() | |
print_exception(exception_tuple[0], exception_tuple[1], | |
exception_tuple[2], file=sbuffer) | |
logging.error(sbuffer.getvalue()) | |
return super(ExceptionalGearmanWorker, self).on_job_exception(current_job, exception_tuple) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment