Skip to content

Commit

Permalink
hub: decorate Task.save with transaction.atomic
Browse files Browse the repository at this point in the history
... to ensure that the task and its parent are updated atomically.
  • Loading branch information
lzaoral committed Aug 24, 2023
1 parent ee6f357 commit da941ba
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions kobo/hub/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,7 @@ def __str__(self):
return u"#%s [method: %s, state: %s, worker: %s, parent: #%s]" % (self.id, self.method, self.get_state_display(), self.worker, self.parent.id)
return u"#%s [method: %s, state: %s, worker: %s]" % (self.id, self.method, self.get_state_display(), self.worker)

@transaction.atomic
def save(self, *args, **kwargs):
if self.id is not None:
self.subtask_count = self.subtasks().count()
Expand Down

0 comments on commit da941ba

Please sign in to comment.