django-rq icon indicating copy to clipboard operation
django-rq copied to clipboard

How to increase timeout of failed jobs

Open eriktelepovsky opened this issue 4 years ago • 12 comments

Hello. Is there a way how to change/increase timeout of failed jobs?

My jobs fail with exception:

rq.timeouts.JobTimeoutException: Task exceeded maximum timeout value

so I increased the DEFAULT_TIMEOUT in RQ_QUEUES setting, but every time I requeue failed jobs, the new setting is ignored and and is used previous timeout value.

eriktelepovsky avatar Nov 15 '20 08:11 eriktelepovsky

Are you getting the queue using django_rq.get_queue()?

selwin avatar Nov 18 '20 01:11 selwin

Hi @selwin. Do you mean when I requeue the failed jobs? I don't do it programmatically. I use django admin action:

image

eriktelepovsky avatar Nov 19 '20 13:11 eriktelepovsky

No, I meant when you're enqueueing the job originally.

selwin avatar Nov 30 '20 07:11 selwin

I'm using method decorator:

from django_rq import job

@job('long_running')
def my_method()
   ...

so yes, I presume it is using get_queue()

eriktelepovsky avatar Nov 30 '20 07:11 eriktelepovsky

Yeah, so I think that should work. Are your settings.py configured correctly? Alternatively you can also do @job('long_running', timeout=1000)

selwin avatar Nov 30 '20 08:11 selwin

When I increase the timeout in the settings, it is applied to all new delayed jobs successfully. But it is not applied to the requeued failed jobs. Old timeout value is used.

eriktelepovsky avatar Nov 30 '20 08:11 eriktelepovsky

Ah ok. Then what’s needed is a feature that allows you to update job.timeout prior to requeueing it.

Unfortunately this feature is not in DjangoRQ yet. If you want, I’ll be happy to accept a PR for this.

On Nov 30, 2020, at 3:54 PM, Erik Telepovský [email protected] wrote:

 When I increase the timeout in the settings, it is applied to all new delayed jobs successfully. But it is not applied to the requeued failed jobs. Old timeout value is used.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

selwin avatar Nov 30 '20 09:11 selwin

I can look into it. Can you guide me where to start?

eriktelepovsky avatar Nov 30 '20 09:11 eriktelepovsky

Create an edit_job_timeout view in https://github.com/rq/django-rq/blob/master/django_rq/views.py#L302

This view should be reachable via job detail page: Selection_281

selwin avatar Nov 30 '20 09:11 selwin

And what about automatic timeout update according to the current settings when job is requeued?

eriktelepovsky avatar Nov 30 '20 10:11 eriktelepovsky

It won't be automated, since the job object is already created and stored in Redis, complete with it's timeout. Automatically updating a value that's already stored, whether it's in DB or Redis whenever a configuration is changed is not recommended.

selwin avatar Nov 30 '20 10:11 selwin

I created a PR #458

eriktelepovsky avatar Dec 03 '20 08:12 eriktelepovsky