diff options
author | Jeff Balogh <jbalogh@mozilla.com> | 2010-08-02 20:44:22 (GMT) |
---|---|---|
committer | Jeff Balogh <jbalogh@mozilla.com> | 2010-08-02 22:58:18 (GMT) |
commit | b4324abe1285c30c8d86604501af39a99b23d602 (patch) | |
tree | 60c7a48809e359ef7fb4c03184b2f43b8453df77 /lib | |
parent | 461626612b9d3a54e89c4068571f3ef34145e2b0 (diff) |
switch to our custom Task class, handle rabbit downtime (bug 583314)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/celeryutils.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/celeryutils.py b/lib/celeryutils.py new file mode 100644 index 0000000..ee81aa1 --- /dev/null +++ b/lib/celeryutils.py @@ -0,0 +1,28 @@ +import logging +import functools + +import celery.decorators +import celery.task + + +log = logging.getLogger('z.celery') + + +class Task(celery.task.Task): + + @classmethod + def apply_async(self, args=None, kwargs=None, **options): + try: + return super(Task, self).apply_async(args, kwargs, **options) + except Exception, e: + log.error('CELERY FAIL: %s' % e) + + +def task(*args, **kw): + # Force usage of our Task subclass. + kw['base'] = Task + wrapper = celery.decorators.task(**kw) + if args: + return wrapper(*args) + else: + return wrapper |