Skip to content

Commit

Permalink
@transaction for select_for_update in update_job_status() (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
bsekachev authored and nmanovic committed Oct 26, 2018
1 parent d11bc91 commit 9e53a21
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cvat/apps/engine/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down

0 comments on commit 9e53a21

Please sign in to comment.