1

Is there a way to specify a "maximum" = inf timeout for a worker? I have some long-running tasks and if something fails due to timeouts I handle it internally within the worker.

Can a specify this through the cli?

Flo
  • 1,367
  • 1
  • 13
  • 27

2 Answers2

2

timeout argument specifies the maximum runtime of the task before it's considered 'lost'. Can be used with @job, Queue, enqueue & enqueue_call.

from rq.decorators import job

@job('low', connection=my_redis_conn, timeout=600)
def long_running_task(x, y):
    # Code

python-rq.org/docs

Himavanth
  • 400
  • 5
  • 15
2

Setting Queue(default_timeout=-1) will do the trick. Here is a reference to their source code:

    def create_job(self, func, args=None, kwargs=None, timeout=None,
               result_ttl=None, ttl=None, failure_ttl=None,
               description=None, depends_on=None, job_id=None,
               meta=None, status=JobStatus.QUEUED, retry=None):
    """Creates a job based on parameters given."""
    timeout = parse_timeout(timeout)

    if timeout is None:
        timeout = self._default_timeout
    elif timeout == 0:
        raise ValueError('0 timeout is not allowed. Use -1 for infinite timeout')
spacegoing
  • 5,056
  • 5
  • 25
  • 42