From 11c7dbb3762e1b76f6f027d7313351d29c3023f2 Mon Sep 17 00:00:00 2001 From: Vincent Driessen Date: Mon, 13 Feb 2012 16:46:39 +0100 Subject: [PATCH] Consistently renamed "failure" -> "failed" queue. Fixes #28. --- rq/worker.py | 8 ++++---- tests/test_worker.py | 19 ++++++++++--------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/rq/worker.py b/rq/worker.py index 239fbe32..c56cb533 100644 --- a/rq/worker.py +++ b/rq/worker.py @@ -88,7 +88,7 @@ class Worker(object): self._horse_pid = 0 self._stopped = False self.log = Logger('worker') - self.failure_queue = Queue('failure') + self.failed_queue = Queue('failed') def validate_queues(self): @@ -268,7 +268,7 @@ class Worker(object): self.log.debug('Data follows:') self.log.debug(e.raw_data) self.log.debug('End of unreadable data.') - self.failure_queue.push_job_id(e.job_id) + self.failed_queue.push_job_id(e.job_id) continue job, queue = result @@ -316,7 +316,7 @@ class Worker(object): try: rv = job.perform() except Exception as e: - fq = self.failure_queue + fq = self.failed_queue self.log.exception(e) self.log.warning('Moving job to %s queue.' % (fq.name,)) @@ -326,7 +326,7 @@ class Worker(object): # ------ REFACTOR THIS ------------------------- job.save() - # ...and put the job on the failure queue + # ...and put the job on the failed queue fq.push_job_id(job.id) # ------ UNTIL HERE ---------------------------- # (should be as easy as fq.enqueue(job) or so) diff --git a/tests/test_worker.py b/tests/test_worker.py index 8a0f2cfc..c450631e 100644 --- a/tests/test_worker.py +++ b/tests/test_worker.py @@ -22,11 +22,11 @@ class TestWorker(RQTestCase): self.assertEquals(w.work(burst=True), True, 'Expected at least some work done.') def test_work_is_unreadable(self): - """Unreadable jobs are put on the failure queue.""" + """Unreadable jobs are put on the failed queue.""" q = Queue() - failure_q = Queue('failure') + failed_q = Queue('failed') - self.assertEquals(failure_q.count, 0) + self.assertEquals(failed_q.count, 0) self.assertEquals(q.count, 0) # NOTE: We have to fake this enqueueing for this test case. @@ -49,15 +49,15 @@ class TestWorker(RQTestCase): w.work(burst=True) # should silently pass self.assertEquals(q.count, 0) - self.assertEquals(failure_q.count, 1) + self.assertEquals(failed_q.count, 1) def test_work_fails(self): - """Failing jobs are put on the failure queue.""" + """Failing jobs are put on the failed queue.""" q = Queue() - failure_q = Queue('failure') + failed_q = Queue('failed') # Preconditions - self.assertEquals(failure_q.count, 0) + self.assertEquals(failed_q.count, 0) self.assertEquals(q.count, 0) # Action @@ -72,13 +72,14 @@ class TestWorker(RQTestCase): # Postconditions self.assertEquals(q.count, 0) - self.assertEquals(failure_q.count, 1) + self.assertEquals(failed_q.count, 1) # Check the job job = Job.fetch(job.id) self.assertEquals(job.origin, q.name) - # should be the original enqueued_at date, not the date of enqueueing to the failure queue + # should be the original enqueued_at date, not the date of enqueueing to + # the failed queue self.assertEquals(job.enqueued_at, enqueued_at_date) self.assertIsNotNone(job.exc_info) # should contain exc_info