Skip to content

Commit

Permalink
hub: do not call save twice in Task.save()
Browse files Browse the repository at this point in the history
... to ensure that the db operation is atomic.

Fixes: c5d7f8e ("Fix calculating the number of task's subtasks in new Django versions")
Related: release-engineering#217 (comment)
  • Loading branch information
lzaoral committed Aug 23, 2023
1 parent ce4fcff commit 50bcc5b
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions kobo/hub/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,9 +606,8 @@ def __str__(self):
return u"#%s [method: %s, state: %s, worker: %s]" % (self.id, self.method, self.get_state_display(), self.worker)

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 50bcc5b

Please sign in to comment.