mirror of https://github.com/rq/rq.git
Fixes an issue where retried jobs should not be put in FailedJobRegistry (#1336)
This commit is contained in:
parent
99f7dc8722
commit
01d71c8984
|
@ -856,7 +856,7 @@ class Worker(object):
|
|||
|
||||
started_job_registry.remove(job, pipeline=pipeline)
|
||||
|
||||
if not self.disable_default_exception_handler:
|
||||
if not self.disable_default_exception_handler and not retry:
|
||||
failed_job_registry = FailedJobRegistry(job.origin, job.connection,
|
||||
job_class=self.job_class)
|
||||
failed_job_registry.add(job, ttl=job.failure_ttl,
|
||||
|
|
|
@ -379,16 +379,19 @@ class TestWorker(RQTestCase):
|
|||
queue = Queue(connection=connection)
|
||||
retry = Retry(max=2)
|
||||
job = queue.enqueue(div_by_zero, retry=retry)
|
||||
registry = FailedJobRegistry(queue=queue)
|
||||
|
||||
worker = Worker([queue])
|
||||
|
||||
# If job if configured to retry, it will be put back in the queue
|
||||
# and not put in the FailedJobRegistry.
|
||||
# This is the original execution
|
||||
queue.empty()
|
||||
worker.handle_job_failure(job, queue)
|
||||
job.refresh()
|
||||
self.assertEqual(job.retries_left, 1)
|
||||
self.assertEqual([job.id], queue.job_ids)
|
||||
self.assertFalse(job in registry)
|
||||
|
||||
# First retry
|
||||
queue.empty()
|
||||
|
@ -403,6 +406,8 @@ class TestWorker(RQTestCase):
|
|||
job.refresh()
|
||||
self.assertEqual(job.retries_left, 0)
|
||||
self.assertEqual([], queue.job_ids)
|
||||
# If a job is no longer retries, it's put in FailedJobRegistry
|
||||
self.assertTrue(job in registry)
|
||||
|
||||
def test_retry_interval(self):
|
||||
"""Retries with intervals are scheduled"""
|
||||
|
|
Loading…
Reference in New Issue