Adds Rollbar support for exceptions

Also formats exceptions in case they are unprintable
This commit is contained in:
Ilan Steemers
2016-01-07 18:50:55 +01:00
parent edb0ffbed3
commit d29c861d09
4 changed files with 28 additions and 4 deletions
+6 -2
View File
@@ -29,7 +29,7 @@ from django import db
import signing
import tasks
from django_q.conf import Conf, logger, psutil, get_ppid
from django_q.conf import Conf, logger, psutil, get_ppid, rollbar
from django_q.models import Task, Success, Schedule
from django_q.status import Stat, Status
from django_q.brokers import get_broker
@@ -363,6 +363,8 @@ def worker(task_queue, result_queue, timer, timeout=Conf.TIMEOUT):
f = getattr(m, func)
except (ValueError, ImportError, AttributeError) as e:
result = (e, False)
if rollbar:
rollbar.report_exc_info()
# We're still going
if not result:
db.close_old_connections()
@@ -372,7 +374,9 @@ def worker(task_queue, result_queue, timer, timeout=Conf.TIMEOUT):
res = f(*task['args'], **task['kwargs'])
result = (res, True)
except Exception as e:
result = (e, False)
result = ('{}'.format(e), False)
if rollbar:
rollbar.report_exc_info()
# Process result
task['result'] = result[0]
task['success'] = result[1]