mirror of https://github.com/rq/rq.git
Fix TimerDeathPenalty not properly handling negative/infinite timeout (#1845)
* Fix TimerDeathPenalty not properly handling negative/infinite timeout * revert back to using exc_info --------- Co-authored-by: Marcus <marcus@us2.ai>
This commit is contained in:
parent
ed59b9248a
commit
e92682c83a
|
@ -110,10 +110,14 @@ class TimerDeathPenalty(BaseDeathPenalty):
|
|||
|
||||
def setup_death_penalty(self):
|
||||
"""Starts the timer."""
|
||||
if self._timeout <= 0:
|
||||
return
|
||||
self._timer = self.new_timer()
|
||||
self._timer.start()
|
||||
|
||||
def cancel_death_penalty(self):
|
||||
"""Cancels the timer."""
|
||||
if self._timeout <= 0:
|
||||
return
|
||||
self._timer.cancel()
|
||||
self._timer = None
|
||||
|
|
|
@ -42,3 +42,10 @@ class TestTimeouts(RQTestCase):
|
|||
self.assertIn(job, failed_job_registry)
|
||||
job.refresh()
|
||||
self.assertIn("rq.timeouts.JobTimeoutException", job.exc_info)
|
||||
|
||||
# Test negative timeout doesn't raise JobTimeoutException,
|
||||
# which implies an unintended immediate timeout.
|
||||
job = q.enqueue(thread_friendly_sleep_func, args=(1,), job_timeout=-1)
|
||||
w.work(burst=True)
|
||||
job.refresh()
|
||||
self.assertIn(job, finished_job_registry)
|
||||
|
|
Loading…
Reference in New Issue