diff --git a/taskflow/engines/action_engine/analyzer.py b/taskflow/engines/action_engine/analyzer.py index ddae1e97..9044fd13 100644 --- a/taskflow/engines/action_engine/analyzer.py +++ b/taskflow/engines/action_engine/analyzer.py @@ -31,9 +31,9 @@ class Analyzer(object): the rest of the runtime system. """ - def __init__(self, compilation, storage): - self._storage = storage - self._execution_graph = compilation.execution_graph + def __init__(self, runtime): + self._storage = runtime.storage + self._execution_graph = runtime.compilation.execution_graph def get_next_nodes(self, node=None): if node is None: diff --git a/taskflow/engines/action_engine/completer.py b/taskflow/engines/action_engine/completer.py index 77ba6859..90ed4458 100644 --- a/taskflow/engines/action_engine/completer.py +++ b/taskflow/engines/action_engine/completer.py @@ -14,6 +14,8 @@ # License for the specific language governing permissions and limitations # under the License. +import weakref + from taskflow.engines.action_engine import executor as ex from taskflow import retry as retry_atom from taskflow import states as st @@ -25,7 +27,7 @@ class Completer(object): """Completes atoms using actions to complete them.""" def __init__(self, runtime): - self._runtime = runtime + self._runtime = weakref.proxy(runtime) self._analyzer = runtime.analyzer self._retry_action = runtime.retry_action self._storage = runtime.storage diff --git a/taskflow/engines/action_engine/runtime.py b/taskflow/engines/action_engine/runtime.py index d8df4705..395ce750 100644 --- a/taskflow/engines/action_engine/runtime.py +++ b/taskflow/engines/action_engine/runtime.py @@ -50,7 +50,7 @@ class Runtime(object): @misc.cachedproperty def analyzer(self): - return an.Analyzer(self._compilation, self._storage) + return an.Analyzer(self) @misc.cachedproperty def runner(self): diff --git a/taskflow/engines/action_engine/scheduler.py b/taskflow/engines/action_engine/scheduler.py index 8e3c64b3..20221830 100644 --- a/taskflow/engines/action_engine/scheduler.py +++ b/taskflow/engines/action_engine/scheduler.py @@ -14,6 +14,8 @@ # License for the specific language governing permissions and limitations # under the License. +import weakref + from taskflow import exceptions as excp from taskflow import retry as retry_atom from taskflow import states as st @@ -23,7 +25,7 @@ from taskflow.types import failure class _RetryScheduler(object): def __init__(self, runtime): - self._runtime = runtime + self._runtime = weakref.proxy(runtime) self._retry_action = runtime.retry_action self._storage = runtime.storage