diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a4ad236..d497a218 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - History panel can now me maximized, minimized and allows to copy column content. - It is possible to use custom tray icons via the environment variables: **BAUH_TRAY_DEFAULT_ICON_PATH** and ** **BAUH_TRAY_UPDATES_ICON_PATH** ( displayed when there are updates ) - Minor UI improvements +- CacheCleaner removed due to random crashes associated with Python threading lock ### Fixes - Snap: diff --git a/bauh/app.py b/bauh/app.py index 5ec98824..568bb67f 100755 --- a/bauh/app.py +++ b/bauh/app.py @@ -10,10 +10,10 @@ from bauh.api.http import HttpClient from bauh.view.core import gems, config from bauh.view.core.controller import GenericSoftwareManager from bauh.view.core.downloader import AdaptableFileDownloader -from bauh.view.util import util, logs, resource from bauh.view.qt.systray import TrayIcon from bauh.view.qt.window import ManageWindow -from bauh.view.util.cache import CacheCleaner, DefaultMemoryCacheFactory +from bauh.view.util import util, logs, resource +from bauh.view.util.cache import DefaultMemoryCacheFactory from bauh.view.util.disk import DefaultDiskCacheLoaderFactory @@ -27,8 +27,7 @@ def main(): i18n_key, i18n = util.get_locale_keys(args.locale) - cache_cleaner = CacheCleaner() - cache_factory = DefaultMemoryCacheFactory(expiration_time=args.cache_exp, cleaner=cache_cleaner) + cache_factory = DefaultMemoryCacheFactory(expiration_time=args.cache_exp) icon_cache = cache_factory.new(args.icon_exp) http_client = HttpClient(logger) @@ -90,8 +89,6 @@ def main(): manage_window.refresh_apps() manage_window.show() - cache_cleaner.start() - sys.exit(app.exec_()) diff --git a/bauh/view/util/cache.py b/bauh/view/util/cache.py index 7a1ba79d..45fb393b 100644 --- a/bauh/view/util/cache.py +++ b/bauh/view/util/cache.py @@ -71,38 +71,15 @@ class DefaultMemoryCache(MemoryCache): self.get(key) -class CacheCleaner(Thread): - - def __init__(self, check_interval: int = 15): - super(CacheCleaner, self).__init__(daemon=True) - self.caches = [] - self.check_interval = check_interval - - def register(self, cache: MemoryCache): - if cache.is_enabled(): - self.caches.append(cache) - - def run(self): - if self.caches: - while True: - for cache in self.caches: - cache.clean_expired() - - time.sleep(self.check_interval) - - class DefaultMemoryCacheFactory(MemoryCacheFactory): - def __init__(self, expiration_time: int, cleaner: CacheCleaner): + def __init__(self, expiration_time: int): """ :param expiration_time: default expiration time for all instantiated caches - :param cleaner """ super(DefaultMemoryCacheFactory, self).__init__() self.expiration_time = expiration_time - self.cleaner = cleaner def new(self, expiration: int = None) -> MemoryCache: instance = DefaultMemoryCache(expiration if expiration is not None else self.expiration_time) - self.cleaner.register(instance) return instance