Fix incorrect worker timeout calculation in SimpleWorker.execute_job (#1304)

In our systems, this bug seemed the be the cause of the disappearing workers: worker keys would get a very small TTL in Redis and would eventually expire, thus mysteriously "disappearing" from dashboards.
main
David Murray 4 years ago committed by GitHub
parent 4e1eb97056
commit 8a0d9f91ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1034,7 +1034,11 @@ class SimpleWorker(Worker):
def execute_job(self, job, queue): def execute_job(self, job, queue):
"""Execute job in same thread/process, do not fork()""" """Execute job in same thread/process, do not fork()"""
timeout = (job.timeout or DEFAULT_WORKER_TTL) + 60 # "-1" means that jobs never timeout. In this case, we should _not_ do -1 + 60 = 59. We should just stick to DEFAULT_WORKER_TTL.
if job.timeout == -1:
timeout = DEFAULT_WORKER_TTL
else:
timeout = (job.timeout or DEFAULT_WORKER_TTL) + 60
return self.perform_job(job, queue, heartbeat_ttl=timeout) return self.perform_job(job, queue, heartbeat_ttl=timeout)

Loading…
Cancel
Save