summaryrefslogtreecommitdiff
path: root/taskflow/patterns/linear_flow.py
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2013-06-28 19:18:48 -0700
committerJoshua Harlow <harlowja@yahoo-inc.com>2013-06-28 19:19:07 -0700
commitade53f72295f82ccfc8a2ae218774022e17816af (patch)
treea80198f3f4e7c1d36f0ff8f99451827a36c50019 /taskflow/patterns/linear_flow.py
parente8e60e884f56f8fef49cf5131f407738e0503410 (diff)
downloadtaskflow-ade53f72295f82ccfc8a2ae218774022e17816af.tar.gz
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
Diffstat (limited to 'taskflow/patterns/linear_flow.py')
-rw-r--r--taskflow/patterns/linear_flow.py9
1 files changed, 5 insertions, 4 deletions
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