Convenience exc_handler registration in __init__.

Allow custom exception handlers to be passed in in the Worker
constructor.
main
Vincent Driessen 12 years ago
parent f457bd9da2
commit cdc3a6c7a9

@ -95,7 +95,7 @@ class Worker(object):
def __init__(self, queues, name=None, default_result_ttl=500, def __init__(self, queues, name=None, default_result_ttl=500,
connection=None): # noqa connection=None, exc_handler=None): # noqa
if connection is None: if connection is None:
connection = get_current_connection() connection = get_current_connection()
self.connection = connection self.connection = connection
@ -116,6 +116,8 @@ class Worker(object):
# By default, push the "move-to-failed-queue" exception handler onto # By default, push the "move-to-failed-queue" exception handler onto
# the stack # the stack
self.push_exc_handler(self.move_to_failed_queue) self.push_exc_handler(self.move_to_failed_queue)
if exc_handler is not None:
self.push_exc_handler(exc_handler)
def validate_queues(self): # noqa def validate_queues(self): # noqa

Loading…
Cancel
Save