Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rqworker timeout

Tags:

I am using django-rq to handle some long-running tasks on my django site. These tasks trip the 180 second timeout of the (I assume) rqworker:

JobTimeoutException: Job exceeded maximum timeout value (180 seconds). 

How can I increase this timeout value? I've tried adding --timeout 360 to the rqworker command but this isn't recognized.

In my python code, my long-running job is called via

        django_rq.enqueue(             populate_trends,             self,         ) 

and have tried

        django_rq.enqueue_call(             func=populate_trends,             args=(self,),             timeout=3600,         ) 

which I noticed in the rq docs but django-rq has no such method it seems.

Update

For now I forked django-rq and added a placeholder fix to increase the timeout. Probably need to work with the project to get a longer term solution. I've started an issue there to discuss.

like image 923
Erik Avatar asked Mar 16 '13 02:03

Erik


People also ask

What is Rqworker?

RQ, also known as Redis Queue, is a Python library that allows developers to enqueue jobs to be processed in the background with workers. The RQ workers will be called when it's time to execute the queue in the background.

How does Django RQ work?

Django-RQ allows you to easily put jobs into any of the queues defined in settings.py . enqueue() returns a job object that provides a variety of information about the job's status, parameters, etc. equeue() takes the function to be enqueued as the first parameter, then a list of arguments.

What are workers Python?

A worker is a Python process that typically runs in the background and exists solely as a work horse to perform lengthy or blocking tasks that you don't want to perform inside web processes.


1 Answers

This seems to be the right way to approach the problem.

queue = django_rq.get_queue('default') queue.enqueue(populate_trends, args=(self,), timeout=500)  

If you need to pass kwargs,

queue = django_rq.get_queue('default') queue.enqueue(populate_trends, args=(self,), kwargs={'x': 1,}, timeout=500)  

Thanks to the selwin at the django-rq project for the help.

like image 182
Erik Avatar answered Sep 21 '22 13:09

Erik