From 9e53a21f46a7d485e4fcab15e20652757d573b57 Mon Sep 17 00:00:00 2001 From: Boris Sekachev <40690378+bsekachev@users.noreply.github.com> Date: Fri, 26 Oct 2018 09:42:48 +0300 Subject: [PATCH] @transaction for select_for_update in update_job_status() (#160) --- cvat/apps/engine/task.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cvat/apps/engine/task.py b/cvat/apps/engine/task.py index d2385b9b1817..626ae47b4f72 100644 --- a/cvat/apps/engine/task.py +++ b/cvat/apps/engine/task.py @@ -187,6 +187,8 @@ def get(tid): return response + +@transaction.atomic def save_job_status(jid, status, user): db_job = models.Job.objects.select_related("segment__task").select_for_update().get(pk = jid) db_task = db_job.segment.task @@ -196,7 +198,7 @@ def save_job_status(jid, status, user): db_job.status = status.value db_job.save() - db_segments = list(db_task.segment_set.prefetch_related('job_set').select_for_update().all()) + db_segments = list(db_task.segment_set.prefetch_related('job_set').all()) db_jobs = [db_segment.job_set.first() for db_segment in db_segments] if len(list(filter(lambda x: StatusChoice(x.status) == StatusChoice.ANNOTATION, db_jobs))) > 0: