Skip to content

Commit

Permalink
Ensure ParallelTaskCollection gets the correct exitcode upon reachi…
Browse files Browse the repository at this point in the history
…ng TERMINATED state.
  • Loading branch information
riccardomurri committed Apr 27, 2018
1 parent 754ac17 commit 0066ed3
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions gc3libs/workflow.py
Expand Up @@ -884,21 +884,22 @@ def submit(self, resubmit=False, targets=None, **extra_args):
self.execution.state = self._state()


def terminated(self):
"""
Set exitcode based on termination status of sub-tasks.
"""
self.execution.returncode = (0, 0)
for task in self.tasks:
if task.execution.returncode != 0:
self.execution.exitcode = 1


def update_state(self, **extra_args):
"""
Update state of all tasks in the collection.
"""
super(ParallelTaskCollection, self).update_state()
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
self.execution.state = self._state()


class ChunkedParameterSweep(ParallelTaskCollection):
Expand Down

0 comments on commit 0066ed3

Please sign in to comment.