From 969ce1cfb26f098fcd3ab792faa572663c84efd0 Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Thu, 16 Nov 2023 14:46:35 -0300 Subject: [PATCH] [view.core.controller] fix: search sometimes hanging when there is only one package type enabled --- CHANGELOG.md | 2 ++ bauh/view/core/controller.py | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4de3db4..d280dbbb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Fixes - AppImage - upgrade fails when the package was initially imported, but later added to bauh's database [#321](https://github.com/vinifmor/bauh/issues/321) +- General + - search sometimes hanging when there is only one package type enabled ### Contributions - German translations by [Mape6](https://github.com/Mape6) diff --git a/bauh/view/core/controller.py b/bauh/view/core/controller.py index f1987914..309d8c39 100755 --- a/bauh/view/core/controller.py +++ b/bauh/view/core/controller.py @@ -144,14 +144,13 @@ class GenericSoftwareManager(SoftwareManager, SettingsController): return available def _search(self, word: str, is_url: bool, man: SoftwareManager, disk_loader, res: SearchResult): - if self._can_work(man): - mti = time.time() - apps_found = man.search(words=word, disk_loader=disk_loader, is_url=is_url, limit=-1) - mtf = time.time() - self.logger.info(f'{man.__class__.__name__} took {mtf - mti:.8f} seconds') + mti = time.time() + apps_found = man.search(words=word, disk_loader=disk_loader, is_url=is_url, limit=-1) + mtf = time.time() + self.logger.info(f'{man.__class__.__name__} took {mtf - mti:.8f} seconds') - res.installed.extend(apps_found.installed) - res.new.extend(apps_found.new) + res.installed.extend(apps_found.installed) + res.new.extend(apps_found.new) def search(self, words: str, disk_loader: DiskCacheLoader = None, limit: int = -1, is_url: bool = False) -> SearchResult: ti = time.time() @@ -171,9 +170,10 @@ class GenericSoftwareManager(SoftwareManager, SettingsController): threads = [] for man in self.managers: - t = Thread(target=self._search, args=(norm_query, is_url, man, disk_loader, res)) - t.start() - threads.append(t) + if self._can_work(man): + t = Thread(target=self._search, args=(norm_query, is_url, man, disk_loader, res)) + t.start() + threads.append(t) for t in threads: t.join()