Skip to content

Commit

Permalink
Merge pull request #221 from lzaoral/hub-tasks-single-save
Browse files Browse the repository at this point in the history
hub: make `Task.save()` atomic
  • Loading branch information
rohanpm committed Aug 27, 2023
2 parents 00c9013 + da941ba commit 8a704d5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions kobo/hub/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,10 +605,10 @@ 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):
# save to db to precalculate subtask counts and obtain an ID (on insert) for stdout and traceback
super(self.__class__, self).save()
self.subtask_count = self.subtasks().count()
if self.id is not None:
self.subtask_count = self.subtasks().count()
super(self.__class__, self).save()
self.logs.save()
if self.parent:
Expand Down

0 comments on commit 8a704d5

Please sign in to comment.