From ade53f72295f82ccfc8a2ae218774022e17816af Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Fri, 28 Jun 2013 19:18:48 -0700 Subject: Store results by add() uuid instead of in array format. Instead of storing the results in the previous linear format, just store the results indexed by the uuid returned from the add() method instead. This allows for easier access to individual task result as well as makes it easier to support non-linear result insertation. Change-Id: Id7461cb74eb1a380b05cf23643e7120df5682224 --- taskflow/patterns/linear_flow.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'taskflow/patterns/linear_flow.py') diff --git a/taskflow/patterns/linear_flow.py b/taskflow/patterns/linear_flow.py index 00ce34a..fd04501 100644 --- a/taskflow/patterns/linear_flow.py +++ b/taskflow/patterns/linear_flow.py @@ -54,8 +54,9 @@ class Flow(base.Flow): # the contract we have with tasks that they will be given the value # they returned if reversion is triggered. self.result_fetcher = None - # Tasks results are stored here... - self.results = [] + # Tasks results are stored here. Lookup is by the uuid that was + # returned from the add function. + self.results = {} # The last index in the order we left off at before being # interrupted (or failing). self._left_off_at = 0 @@ -173,7 +174,7 @@ class Flow(base.Flow): runner.result = result # Alter the index we have ran at. self._left_off_at += 1 - self.results.append((runner.task, copy.deepcopy(result))) + self.results[runner.uuid] = copy.deepcopy(result) self._on_task_finish(context, runner.task, result) except Exception as e: cause = utils.FlowFailure(runner.task, self, e) @@ -225,7 +226,7 @@ class Flow(base.Flow): @decorators.locked def reset(self): super(Flow, self).reset() - self.results = [] + self.results = {} self.result_fetcher = None self._accumulator.reset() self._left_off_at = 0 -- cgit v1.2.1