Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJeff Balogh <jbalogh@mozilla.com>2010-08-02 20:44:22 (GMT)
committer Jeff Balogh <jbalogh@mozilla.com>2010-08-02 22:58:18 (GMT)
commitb4324abe1285c30c8d86604501af39a99b23d602 (patch)
tree60c7a48809e359ef7fb4c03184b2f43b8453df77 /lib
parent461626612b9d3a54e89c4068571f3ef34145e2b0 (diff)
switch to our custom Task class, handle rabbit downtime (bug 583314)
Diffstat (limited to 'lib')
-rw-r--r--lib/celeryutils.py28
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