Skip to content

Commit

Permalink
Merge pull request #44 from roboduels/develop
Browse files Browse the repository at this point in the history
Implement retry mechansim on redis queue
  • Loading branch information
sarikaya authored May 8, 2024
2 parents d429047 + 3991629 commit 56a233d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
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

0 comments on commit 56a233d

Please sign in to comment.