mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 04:44:15 +02:00
CacheCleaner removed due to random crashes associated with Python threading lock
This commit is contained in:
@@ -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.
|
- 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 )
|
- 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
|
- Minor UI improvements
|
||||||
|
- CacheCleaner removed due to random crashes associated with Python threading lock
|
||||||
|
|
||||||
### Fixes
|
### Fixes
|
||||||
- Snap:
|
- Snap:
|
||||||
|
|||||||
@@ -10,10 +10,10 @@ from bauh.api.http import HttpClient
|
|||||||
from bauh.view.core import gems, config
|
from bauh.view.core import gems, config
|
||||||
from bauh.view.core.controller import GenericSoftwareManager
|
from bauh.view.core.controller import GenericSoftwareManager
|
||||||
from bauh.view.core.downloader import AdaptableFileDownloader
|
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.systray import TrayIcon
|
||||||
from bauh.view.qt.window import ManageWindow
|
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
|
from bauh.view.util.disk import DefaultDiskCacheLoaderFactory
|
||||||
|
|
||||||
|
|
||||||
@@ -27,8 +27,7 @@ def main():
|
|||||||
|
|
||||||
i18n_key, i18n = util.get_locale_keys(args.locale)
|
i18n_key, i18n = util.get_locale_keys(args.locale)
|
||||||
|
|
||||||
cache_cleaner = CacheCleaner()
|
cache_factory = DefaultMemoryCacheFactory(expiration_time=args.cache_exp)
|
||||||
cache_factory = DefaultMemoryCacheFactory(expiration_time=args.cache_exp, cleaner=cache_cleaner)
|
|
||||||
icon_cache = cache_factory.new(args.icon_exp)
|
icon_cache = cache_factory.new(args.icon_exp)
|
||||||
|
|
||||||
http_client = HttpClient(logger)
|
http_client = HttpClient(logger)
|
||||||
@@ -90,8 +89,6 @@ def main():
|
|||||||
manage_window.refresh_apps()
|
manage_window.refresh_apps()
|
||||||
manage_window.show()
|
manage_window.show()
|
||||||
|
|
||||||
cache_cleaner.start()
|
|
||||||
|
|
||||||
sys.exit(app.exec_())
|
sys.exit(app.exec_())
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -71,38 +71,15 @@ class DefaultMemoryCache(MemoryCache):
|
|||||||
self.get(key)
|
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):
|
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 expiration_time: default expiration time for all instantiated caches
|
||||||
:param cleaner
|
|
||||||
"""
|
"""
|
||||||
super(DefaultMemoryCacheFactory, self).__init__()
|
super(DefaultMemoryCacheFactory, self).__init__()
|
||||||
self.expiration_time = expiration_time
|
self.expiration_time = expiration_time
|
||||||
self.cleaner = cleaner
|
|
||||||
|
|
||||||
def new(self, expiration: int = None) -> MemoryCache:
|
def new(self, expiration: int = None) -> MemoryCache:
|
||||||
instance = DefaultMemoryCache(expiration if expiration is not None else self.expiration_time)
|
instance = DefaultMemoryCache(expiration if expiration is not None else self.expiration_time)
|
||||||
self.cleaner.register(instance)
|
|
||||||
return instance
|
return instance
|
||||||
|
|||||||
Reference in New Issue
Block a user