diff options
| author | Julian Andres Klode <jak@debian.org> | 2015-06-10 17:11:01 +0200 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2015-06-10 17:11:01 +0200 |
| commit | 2ebe65984aff59eb27de849351c4bbb9ca25351b (patch) | |
| tree | 4a4abd61c35fd9a0b4ddce272b2c0714c301746c | |
| parent | e3009e4a955dbad7eed8cc1765b38f8ebd948fd5 (diff) | |
| download | python-apt-2ebe65984aff59eb27de849351c4bbb9ca25351b.tar.gz | |
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
| -rw-r--r-- | apt/cache.py | 9 |
1 files 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 |
