31👍
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.
9👍
An update:
You can pass the timeout parameter as keyword argument to the @job decorator of django-rq. Notice that you have to pass the queue name argument first.
@job("default", timeout=600)
def long_running_task():
...
- [Django]-How to change empty_label for modelForm choice field?
- [Django]-Currently using Django "Evolution", is "South" better and worth switching?
- [Django]-How to limit fields in django-admin depending on user?
3👍
Use job_timeout
:
queue.enqueue(worker_func, *args, **kwargs, job_timeout=200)
As it has been pointed out by Stephen Blair the timeout
parameter doesn’t work for newer versions of rq:
timeout
argument onqueue.enqueue()
has been deprecated in favor
ofjob_timeout
.
https://github.com/rq/rq/blob/master/CHANGES.md#10-2019-04-06
Where job_timeout
has just the same effect as timeout
had.
- [Django]-Django.core.exceptions.ImproperlyConfigured: Requested setting USE_I18N, but settings are not configured
- [Django]-Setting expiration time to django password reset token
- [Django]-How to model a postal address
1👍
For clarity for people using functions with arguments, You can pass the timeout as below
string_to_print = "Hello World"
queue = django_rq.get_queue('default')
queue.enqueue(print_input, to_print=string_to_print, timeout=600)
for a function taking arguments like below
@job
def print_input(to_print):
print "The input supplied is ", to_print
- [Django]-How to show query parameter options in Django REST Framework – Swagger
- [Django]-Django 1.7 migrations won't recreate a dropped table, why?
- [Django]-Uncaught TypeError: Cannot read property 'ownerDocument' of undefined