From f301ae60c78ef0be1b00cdb1b7ee7c6c8f3e9afb Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Mon, 23 Jul 2012 13:10:49 +0200 Subject: [PATCH] [entropy.graph] Graph: drop __del__ (just use destroy() instead) to help automatic GC --- lib/entropy/cli.py | 2 -- lib/entropy/client/interfaces/dep.py | 5 ----- lib/entropy/graph.py | 28 ---------------------------- 3 files changed, 35 deletions(-) diff --git a/lib/entropy/cli.py b/lib/entropy/cli.py index bd8b1474d..f0cda6914 100644 --- a/lib/entropy/cli.py +++ b/lib/entropy/cli.py @@ -849,7 +849,6 @@ def _revgraph_package(entropy_client, installed_pkg_id, package, dbconn, del stack graph.destroy() - del graph return 0 def graph_packages(packages, entropy_client, complete = False, @@ -947,7 +946,6 @@ def _graph_package(match, package, entropy_intf, show_complete = False, del stack graph.destroy() - del graph return 0 def _graph_to_stdout(entropy_client, graph, start_item, diff --git a/lib/entropy/client/interfaces/dep.py b/lib/entropy/client/interfaces/dep.py index a53f1bd9b..008dee6ae 100644 --- a/lib/entropy/client/interfaces/dep.py +++ b/lib/entropy/client/interfaces/dep.py @@ -1840,7 +1840,6 @@ class CalculatorsMixin: if deps_not_found: graph.destroy() - del graph raise DependenciesNotFound(deps_not_found) # get adjacency map before it gets destroyed by solve() @@ -1850,7 +1849,6 @@ class CalculatorsMixin: deptree = graph.solve() if 0 in deptree: graph.destroy() - del graph raise KeyError("Graph contains a dep_level == 0") # now check and report dependencies with colliding scope and in case, @@ -1865,7 +1863,6 @@ class CalculatorsMixin: len(x) > 1] if _colliding_deps: graph.destroy() - del graph raise DependenciesCollision(_colliding_deps) # now use the ASAP herustic to anticipate post-dependencies @@ -1887,7 +1884,6 @@ class CalculatorsMixin: reverse_tree[level_count] = deptree[key] graph.destroy() - del graph reverse_tree[0] = deptree_conflicts if self.xcache: @@ -2345,7 +2341,6 @@ class CalculatorsMixin: del flat_dep_tree graph.destroy() - del graph if self.xcache: self._cacher.push(c_hash, deptree) diff --git a/lib/entropy/graph.py b/lib/entropy/graph.py index 56181338b..645388437 100644 --- a/lib/entropy/graph.py +++ b/lib/entropy/graph.py @@ -35,12 +35,6 @@ class GraphNode(object): self.__item = item self.__arches = set() - def __del__(self): - try: - self._clear() - except (NameError, AttributeError): - pass - def _clear(self): """ Clear the object @@ -154,12 +148,6 @@ class GraphArchSet(object): self.__origin = starting_point self.__endpoints = set() - def __del__(self): - try: - self._clear() - except (NameError, AttributeError): - pass - def _clear(self): """ Cleanup the object @@ -245,16 +233,6 @@ class TopologicalSorter(object): self.__adjacency_map = adjacency_map self.__stack = Lifo() - def __del__(self): - try: - self.__adjacency_map.clear() - except (NameError, AttributeError): - pass - try: - self.__stack.clear() - except (NameError, AttributeError): - pass - def __topological_sort_visit_node(self, node, low, result): """ Internal method, visits a node ad push to stack. @@ -385,12 +363,6 @@ class Graph(object): self.__archs_map = {} self.__graph_map_cache = None - def __del__(self): - try: - self.destroy() - except (AttributeError, NameError): - pass - def destroy(self): """ Cleanup any reference.