Skip to content

Commit

Permalink
Avoid timing out when no timeout is set (#4653)
Browse files Browse the repository at this point in the history
* soft limits should not exceed if they are set to run infinitely

* use a variable to explain magic number
  • Loading branch information
Omer Lachish committed Feb 18, 2020
1 parent abbfd59 commit 7124bc9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions redash/tasks/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,13 @@ def stop_executing_job(self, job):
self.log.warning("Job %s has been cancelled.", job.id)

def soft_limit_exceeded(self, job):
seconds_under_monitor = (utcnow() - self.monitor_started).seconds
return seconds_under_monitor > job.timeout + self.grace_period
job_has_time_limit = job.timeout != -1

if job_has_time_limit:
seconds_under_monitor = (utcnow() - self.monitor_started).seconds
return seconds_under_monitor > job.timeout + self.grace_period
else:
return False

def enforce_hard_limit(self, job):
self.log.warning(
Expand Down

0 comments on commit 7124bc9

Please sign in to comment.