Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement retry mechansim on redis queue #44

Merged
merged 1 commit into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cvat/apps/engine/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ def create(tid, data):
"""Schedule the task"""
q = django_rq.get_queue('default')
q.enqueue_call(func=_create_thread, args=(tid, data),
job_id="/api/v1/tasks/{}".format(tid))
job_id="/api/v1/tasks/{}".format(tid),
retry=django_rq.Retry(max=3, interval=[10, 60, 180]))

@transaction.atomic
def rq_handler(job, exc_type, exc_value, traceback):
Expand Down
10 changes: 7 additions & 3 deletions cvat/apps/engine/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ def create(self, request):
'tmp_file': filename,
'tmp_file_descriptor': fd,
},
retry=django_rq.Retry(max=3, interval=[10, 60, 180])
)

else:
Expand Down Expand Up @@ -565,7 +566,8 @@ def retrieve(self, request, pk=None):
args=(pk, 'task_dump.zip'),
job_id=rq_id,
meta={'request_time': timezone.localtime()},
result_ttl=ttl, failure_ttl=ttl)
result_ttl=ttl, failure_ttl=ttl,
retry=django_rq.Retry(max=3, interval=[10, 60, 180]))
return Response(status=status.HTTP_202_ACCEPTED)

else:
Expand Down Expand Up @@ -1592,7 +1594,8 @@ def _import_annotations(request, rq_id, rq_func, pk, format_name):
rq_job = queue.enqueue_call(
func=rq_func,
args=(pk, filename, format_name),
job_id=rq_id
job_id=rq_id,
retry=django_rq.Retry(max=3, interval=[10, 60, 180])
)
rq_job.meta['tmp_file'] = filename
rq_job.meta['tmp_file_descriptor'] = fd
Expand Down Expand Up @@ -1686,7 +1689,8 @@ def _export_annotations(db_instance, rq_id, request, format_name, action, callba
queue.enqueue_call(func=callback,
args=(db_instance.id, format_name, server_address), job_id=rq_id,
meta={'request_time': timezone.localtime()},
result_ttl=ttl, failure_ttl=ttl)
result_ttl=ttl, failure_ttl=ttl,
retry=django_rq.Retry(max=3, interval=[10, 60, 180]))
return Response(status=status.HTTP_202_ACCEPTED)


Expand Down
Loading