From 5067b802a26f410c24dfafef004084fee4687e3b Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Mon, 30 Dec 2013 16:03:20 -0800 Subject: [PATCH] Avoid not_done naming conflict In order to make understanding the usage of the 'not_done' variable easier allow the schedule to take in the list it will be appending to instead of relying on a function local variable (which is overwritten in the contained while loop) Change-Id: I60c0c970d8fb444983e0d8b567ebe82c47e13d96 --- taskflow/engines/action_engine/graph_action.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/taskflow/engines/action_engine/graph_action.py b/taskflow/engines/action_engine/graph_action.py index 7fe80a92..5a79a427 100644 --- a/taskflow/engines/action_engine/graph_action.py +++ b/taskflow/engines/action_engine/graph_action.py @@ -59,20 +59,18 @@ class FutureGraphAction(object): return st.SUSPENDED if was_suspended else st.REVERTED def _run(self, running, schedule_node, complete_node, get_next_nodes): - not_done = [] - def schedule(nodes): + def schedule(nodes, not_done): for node in nodes: future = schedule_node(node) if future is not None: not_done.append(future) else: - schedule(get_next_nodes(node)) - - schedule(get_next_nodes()) + schedule(get_next_nodes(node), not_done) failures = [] - + not_done = [] + schedule(get_next_nodes(), not_done) was_suspended = False while not_done: # NOTE(imelnikov): if timeout occurs before any of futures @@ -93,7 +91,7 @@ class FutureGraphAction(object): if next_nodes: if running() and not failures: - schedule(next_nodes) + schedule(next_nodes, not_done) else: # NOTE(imelnikov): engine stopped while there were # still some tasks to do, so we either failed