Consistently renamed "failure" -> "failed" queue.

Fixes #28.
main
Vincent Driessen 13 years ago
parent 9f5b1545b6
commit 11c7dbb376

@ -88,7 +88,7 @@ class Worker(object):
self._horse_pid = 0 self._horse_pid = 0
self._stopped = False self._stopped = False
self.log = Logger('worker') self.log = Logger('worker')
self.failure_queue = Queue('failure') self.failed_queue = Queue('failed')
def validate_queues(self): def validate_queues(self):
@ -268,7 +268,7 @@ class Worker(object):
self.log.debug('Data follows:') self.log.debug('Data follows:')
self.log.debug(e.raw_data) self.log.debug(e.raw_data)
self.log.debug('End of unreadable 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 continue
job, queue = result job, queue = result
@ -316,7 +316,7 @@ class Worker(object):
try: try:
rv = job.perform() rv = job.perform()
except Exception as e: except Exception as e:
fq = self.failure_queue fq = self.failed_queue
self.log.exception(e) self.log.exception(e)
self.log.warning('Moving job to %s queue.' % (fq.name,)) self.log.warning('Moving job to %s queue.' % (fq.name,))
@ -326,7 +326,7 @@ class Worker(object):
# ------ REFACTOR THIS ------------------------- # ------ REFACTOR THIS -------------------------
job.save() job.save()
# ...and put the job on the failure queue # ...and put the job on the failed queue
fq.push_job_id(job.id) fq.push_job_id(job.id)
# ------ UNTIL HERE ---------------------------- # ------ UNTIL HERE ----------------------------
# (should be as easy as fq.enqueue(job) or so) # (should be as easy as fq.enqueue(job) or so)

@ -22,11 +22,11 @@ class TestWorker(RQTestCase):
self.assertEquals(w.work(burst=True), True, 'Expected at least some work done.') self.assertEquals(w.work(burst=True), True, 'Expected at least some work done.')
def test_work_is_unreadable(self): def test_work_is_unreadable(self):
"""Unreadable jobs are put on the failure queue.""" """Unreadable jobs are put on the failed queue."""
q = 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) self.assertEquals(q.count, 0)
# NOTE: We have to fake this enqueueing for this test case. # 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 w.work(burst=True) # should silently pass
self.assertEquals(q.count, 0) self.assertEquals(q.count, 0)
self.assertEquals(failure_q.count, 1) self.assertEquals(failed_q.count, 1)
def test_work_fails(self): def test_work_fails(self):
"""Failing jobs are put on the failure queue.""" """Failing jobs are put on the failed queue."""
q = Queue() q = Queue()
failure_q = Queue('failure') failed_q = Queue('failed')
# Preconditions # Preconditions
self.assertEquals(failure_q.count, 0) self.assertEquals(failed_q.count, 0)
self.assertEquals(q.count, 0) self.assertEquals(q.count, 0)
# Action # Action
@ -72,13 +72,14 @@ class TestWorker(RQTestCase):
# Postconditions # Postconditions
self.assertEquals(q.count, 0) self.assertEquals(q.count, 0)
self.assertEquals(failure_q.count, 1) self.assertEquals(failed_q.count, 1)
# Check the job # Check the job
job = Job.fetch(job.id) job = Job.fetch(job.id)
self.assertEquals(job.origin, q.name) 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.assertEquals(job.enqueued_at, enqueued_at_date)
self.assertIsNotNone(job.exc_info) # should contain exc_info self.assertIsNotNone(job.exc_info) # should contain exc_info

Loading…
Cancel
Save