ariatosca-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mxmrlv <...@git.apache.org>
Subject [GitHub] incubator-ariatosca pull request #159: ARIA-284 Cleanup and optimize the tas...
Date Sun, 25 Jun 2017 10:59:22 GMT
Github user mxmrlv commented on a diff in the pull request:

    https://github.com/apache/incubator-ariatosca/pull/159#discussion_r123895803
  
    --- Diff: aria/orchestrator/workflows/core/engine.py ---
    @@ -129,16 +103,70 @@ def _handle_executable_task(self, ctx, task, executing_tasks):
                 name=task.name
             )
     
    -        executing_tasks.append(task)
    -
             if not task._stub_type:
                 events.sent_task_signal.send(op_ctx)
             task_executor.execute(op_ctx)
     
         @staticmethod
    -    def _handle_ended_tasks(ctx, task, executing_tasks):
    -        executing_tasks.remove(task)
    +    def _handle_ended_tasks(task):
             if task.status == models.Task.FAILED and not task.ignore_failure:
                 raise exceptions.ExecutorException('Workflow failed')
    -        else:
    -            ctx._graph.remove_node(task)
    +
    +
    +class _TasksTracker(object):
    +    def __init__(self, ctx):
    +        self._ctx = ctx
    +        self._tasks = ctx.execution.tasks
    +        self._executed_tasks = [task for task in self._tasks if task.has_ended()]
    +        self._executable_tasks = list(set(self._tasks) - set(self._executed_tasks))
    +        self._executing_tasks = []
    +
    +    @property
    +    def all_tasks_consumed(self):
    +        return len(self._executed_tasks) == len(self._tasks) and len(self._executing_tasks)
== 0
    +
    +    def executing_(self, task):
    +        # Task executing could be retrying (thus removed and added earlier)
    +        if task not in self._executing_tasks:
    +            self._executable_tasks.remove(task)
    +            self._executing_tasks.append(task)
    +
    +    def finished_(self, task):
    +        self._executing_tasks.remove(task)
    +        self._executed_tasks.append(task)
    +
    +    @property
    +    def ended_tasks(self):
    +        for task in self.executing_tasks:
    +            if task.has_ended():
    +                yield task
    +
    +    @property
    +    def executable_tasks(self):
    +        now = datetime.utcnow()
    +        # we need both list since retrying task are in the executing task list.
    --- End diff --
    
    lists


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message