From 2ebe65984aff59eb27de849351c4bbb9ca25351b Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 10 Jun 2015 17:11:01 +0200 Subject: apt/cache.py: Work around a cyclic reference from Cache to its methods This makes the number of FDs stable in the test case and makes sure that our cache gets closed if it is deleted. Closes: #745487 --- apt/cache.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/apt/cache.py b/apt/cache.py index f94f2146..c8615caf 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -78,8 +78,8 @@ class Cache(object): self._changes_count = -1 self._sorted_set = None - self.connect("cache_post_open", self._inc_changes_count) - self.connect("cache_post_change", self._inc_changes_count) + self.connect("cache_post_open", "_inc_changes_count") + self.connect("cache_post_change", "_inc_changes_count") if memonly: # force apt to build its caches in memory apt_pkg.config.set("Dir::Cache::pkgcache", "") @@ -135,7 +135,10 @@ class Cache(object): """ internal helper to run a callback """ if name in self._callbacks: for callback in self._callbacks[name]: - callback() + if callback == '_inc_changes_count': + self._inc_changes_count() + else: + callback() def open(self, progress=None): """ Open the package cache, after that it can be used like -- cgit v1.2.3