Skip to content

Commit

Permalink
Only mark a ParallelTaskCollection as changed if state actually cha…
Browse files Browse the repository at this point in the history
…nged.
  • Loading branch information
riccardomurri committed Apr 27, 2018
1 parent cbc2b4f commit f0f72a4
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions gc3libs/workflow.py
Expand Up @@ -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):
Expand Down

0 comments on commit f0f72a4

Please sign in to comment.