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:
		@@ -31,9 +31,9 @@ class Analyzer(object):
 | 
				
			|||||||
    the rest of the runtime system.
 | 
					    the rest of the runtime system.
 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __init__(self, compilation, storage):
 | 
					    def __init__(self, runtime):
 | 
				
			||||||
        self._storage = storage
 | 
					        self._storage = runtime.storage
 | 
				
			||||||
        self._execution_graph = compilation.execution_graph
 | 
					        self._execution_graph = runtime.compilation.execution_graph
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def get_next_nodes(self, node=None):
 | 
					    def get_next_nodes(self, node=None):
 | 
				
			||||||
        if node is None:
 | 
					        if node is None:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -14,6 +14,8 @@
 | 
				
			|||||||
#    License for the specific language governing permissions and limitations
 | 
					#    License for the specific language governing permissions and limitations
 | 
				
			||||||
#    under the License.
 | 
					#    under the License.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import weakref
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from taskflow.engines.action_engine import executor as ex
 | 
					from taskflow.engines.action_engine import executor as ex
 | 
				
			||||||
from taskflow import retry as retry_atom
 | 
					from taskflow import retry as retry_atom
 | 
				
			||||||
from taskflow import states as st
 | 
					from taskflow import states as st
 | 
				
			||||||
@@ -25,7 +27,7 @@ class Completer(object):
 | 
				
			|||||||
    """Completes atoms using actions to complete them."""
 | 
					    """Completes atoms using actions to complete them."""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __init__(self, runtime):
 | 
					    def __init__(self, runtime):
 | 
				
			||||||
        self._runtime = runtime
 | 
					        self._runtime = weakref.proxy(runtime)
 | 
				
			||||||
        self._analyzer = runtime.analyzer
 | 
					        self._analyzer = runtime.analyzer
 | 
				
			||||||
        self._retry_action = runtime.retry_action
 | 
					        self._retry_action = runtime.retry_action
 | 
				
			||||||
        self._storage = runtime.storage
 | 
					        self._storage = runtime.storage
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -50,7 +50,7 @@ class Runtime(object):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    @misc.cachedproperty
 | 
					    @misc.cachedproperty
 | 
				
			||||||
    def analyzer(self):
 | 
					    def analyzer(self):
 | 
				
			||||||
        return an.Analyzer(self._compilation, self._storage)
 | 
					        return an.Analyzer(self)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @misc.cachedproperty
 | 
					    @misc.cachedproperty
 | 
				
			||||||
    def runner(self):
 | 
					    def runner(self):
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -14,6 +14,8 @@
 | 
				
			|||||||
#    License for the specific language governing permissions and limitations
 | 
					#    License for the specific language governing permissions and limitations
 | 
				
			||||||
#    under the License.
 | 
					#    under the License.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import weakref
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from taskflow import exceptions as excp
 | 
					from taskflow import exceptions as excp
 | 
				
			||||||
from taskflow import retry as retry_atom
 | 
					from taskflow import retry as retry_atom
 | 
				
			||||||
from taskflow import states as st
 | 
					from taskflow import states as st
 | 
				
			||||||
@@ -23,7 +25,7 @@ from taskflow.types import failure
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
class _RetryScheduler(object):
 | 
					class _RetryScheduler(object):
 | 
				
			||||||
    def __init__(self, runtime):
 | 
					    def __init__(self, runtime):
 | 
				
			||||||
        self._runtime = runtime
 | 
					        self._runtime = weakref.proxy(runtime)
 | 
				
			||||||
        self._retry_action = runtime.retry_action
 | 
					        self._retry_action = runtime.retry_action
 | 
				
			||||||
        self._storage = runtime.storage
 | 
					        self._storage = runtime.storage
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user