From f9897ea920beacbe4f6b881e6a5645c1376297c1 Mon Sep 17 00:00:00 2001 From: Wojciech Bederski Date: Tue, 21 May 2013 17:35:18 +0200 Subject: [PATCH 1/2] register_sentry breaks failed queue when func cannot be imported --- tests/test_sentry.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests/test_sentry.py diff --git a/tests/test_sentry.py b/tests/test_sentry.py new file mode 100644 index 0000000..3fa4737 --- /dev/null +++ b/tests/test_sentry.py @@ -0,0 +1,29 @@ +from tests import RQTestCase +from rq import Queue, Worker, get_failed_queue +from rq.contrib.sentry import register_sentry + + +class FakeSentry(object): + def captureException(self, *args, **kwds): + pass # we cannot check this, because worker forks + + +class TestSentry(RQTestCase): + + def test_work_fails(self): + """Non importable jobs should be put on the failed queue event with sentry""" + q = Queue() + failed_q = get_failed_queue() + + # Action + q.enqueue('_non.importable.job') + self.assertEquals(q.count, 1) + + w = Worker([q]) + register_sentry(FakeSentry(), w) + + w.work(burst=True) + + # Postconditions + self.assertEquals(failed_q.count, 1) + self.assertEquals(q.count, 0) From 0198916856bdb416f68bbae4637064d2f3cab5d8 Mon Sep 17 00:00:00 2001 From: Selwin Ong Date: Tue, 30 Jul 2013 19:31:51 +0700 Subject: [PATCH 2/2] Fixes an issue where register_sentry breaks when logging jobs with unimportable function. --- rq/contrib/sentry.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rq/contrib/sentry.py b/rq/contrib/sentry.py index abaef72..4b776d1 100644 --- a/rq/contrib/sentry.py +++ b/rq/contrib/sentry.py @@ -7,7 +7,7 @@ def register_sentry(client, worker): exc_info=exc_info, extra={ 'job_id': job.id, - 'func': job.func, + 'func': job.func_name, 'args': job.args, 'kwargs': job.kwargs, 'description': job.description,