Give the GC a break

Instead of retaining cycles which the GC will have
a harder time breaking, give it a break and use the
knowledge that the associated objects will always exist
while the runtime object does to just use a weakref
proxy so that the GC will have a easier time breaking
this cycle.

Change-Id: I6241b2f33354fa58565835a5f08e5766aa601704
This commit is contained in:
Joshua Harlow
2015-03-17 16:26:38 -07:00
parent f8af1289c9
commit 374d91d34b
4 changed files with 10 additions and 6 deletions

View File

@@ -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:

View File

@@ -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

View File

@@ -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):

View File

@@ -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