mirror of https://github.com/rq/rq.git
parent
9f5b1545b6
commit
11c7dbb376
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue