From f0f72a4bce56b3bb8e8aa8655d0cb7544ce1a0d5 Mon Sep 17 00:00:00 2001 From: Riccardo Murri Date: Fri, 27 Apr 2018 14:37:30 +0200 Subject: [PATCH] Only mark a `ParallelTaskCollection` as changed if state actually changed. --- gc3libs/workflow.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/gc3libs/workflow.py b/gc3libs/workflow.py index 4664a1e3..d1652f47 100755 --- a/gc3libs/workflow.py +++ b/gc3libs/workflow.py @@ -883,20 +883,22 @@ def submit(self, resubmit=False, targets=None, **extra_args): raise self.execution.state = self._state() + def update_state(self, **extra_args): """ Update state of all tasks in the collection. """ super(ParallelTaskCollection, self).update_state() - self.execution.state = self._state() - if self.execution.state == Run.State.TERMINATED: - self.execution.returncode = (0, 0) - # set exitcode based on returncode of sub-tasks - for task in self.tasks: - if task.execution.returncode != 0: - self.execution.exitcode = 1 - # FIXME: incorrectly sets `changed` each time it's called! - self.changed = True + current_state = self.execution.state + updated_state = self._state() + if current_state != updated_state: + if updated_state == Run.State.TERMINATED: + self.execution.returncode = (0, 0) + # set exitcode based on returncode of sub-tasks + for task in self.tasks: + if task.execution.returncode != 0: + self.execution.exitcode = 1 + self.execution.state = updated_state class ChunkedParameterSweep(ParallelTaskCollection):