summaryrefslogtreecommitdiff
path: root/taskflow/patterns/linear_flow.py
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2013-07-08 11:19:09 -0700
committerJoshua Harlow <harlowja@yahoo-inc.com>2013-07-08 11:19:09 -0700
commit61f3944a4f9cd2fb00690b945a4aa7b4736cd2e7 (patch)
tree43b7e7d8493e8158e9eba0cc6004fa96c826a3e7 /taskflow/patterns/linear_flow.py
parentb89eefea1804ede071747f558bb11571090445b3 (diff)
downloadtaskflow-61f3944a4f9cd2fb00690b945a4aa7b4736cd2e7.tar.gz
Add helper reset internals function.
Use a little helper function to reset the internal state of the flow when needed instead of duplicating code that does this. Change-Id: I51d83538a2920c7d387ffd1756e8d99413f4077e
Diffstat (limited to 'taskflow/patterns/linear_flow.py')
-rw-r--r--taskflow/patterns/linear_flow.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/taskflow/patterns/linear_flow.py b/taskflow/patterns/linear_flow.py
index 9a9df15..149842f 100644
--- a/taskflow/patterns/linear_flow.py
+++ b/taskflow/patterns/linear_flow.py
@@ -70,11 +70,14 @@ class Flow(base.Flow):
assert isinstance(task, collections.Callable)
r = utils.Runner(task)
r.runs_before = list(reversed(self._runners))
- self._connected = False
- self._leftoff_at = None
self._runners.append(r)
+ self._reset_internals()
return r.uuid
+ def _reset_internals(self):
+ self._connected = False
+ self._leftoff_at = None
+
def _associate_providers(self, runner):
# Ensure that some previous task provides this input.
who_provides = {}
@@ -112,10 +115,8 @@ class Flow(base.Flow):
if index_removed == -1:
raise ValueError("No runner found with uuid %s" % (uuid))
else:
- # Ensure that we reset out internal state after said removal.
removed = self._runners.pop(index_removed)
- self._connected = False
- self._leftoff_at = None
+ self._reset_internals()
# Go and remove it from any runner after the removed runner since
# those runners may have had an attachment to it.
for r in self._runners[index_removed:]:
@@ -257,8 +258,7 @@ class Flow(base.Flow):
self.results = {}
self.resumer = None
self._accumulator.reset()
- self._leftoff_at = None
- self._connected = False
+ self._reset_internals()
@decorators.locked
def rollback(self, context, cause):