mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-12 03:04:16 +02:00
enhancement: marked several threads as 'daemon' for a faster termination
This commit is contained in:
@@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|||||||
- parallelized installed packages reading
|
- parallelized installed packages reading
|
||||||
- parallelized search
|
- parallelized search
|
||||||
- adding a new project definition/setup (`pyproject.toml`) file to comply with the latest standards
|
- adding a new project definition/setup (`pyproject.toml`) file to comply with the latest standards
|
||||||
|
- faster exit (threaded calls won't be waited)
|
||||||
- UI
|
- UI
|
||||||
- the "Skip" button on the initialization panel is now enabled after 10 seconds [#310](https://github.com/vinifmor/bauh/issues/310)
|
- the "Skip" button on the initialization panel is now enabled after 10 seconds [#310](https://github.com/vinifmor/bauh/issues/310)
|
||||||
- faster package icons download
|
- faster package icons download
|
||||||
|
|||||||
@@ -1332,7 +1332,7 @@ class ArchManager(SoftwareManager, SettingsController):
|
|||||||
|
|
||||||
thread_fill_aur = None
|
thread_fill_aur = None
|
||||||
if aur_replacers:
|
if aur_replacers:
|
||||||
thread_fill_aur = Thread(target=self._fill_aur_providers, args=(aur_replacers, actual_replacers))
|
thread_fill_aur = Thread(target=self._fill_aur_providers, args=(aur_replacers, actual_replacers), daemon=True)
|
||||||
thread_fill_aur.start()
|
thread_fill_aur.start()
|
||||||
|
|
||||||
if repo_replacers:
|
if repo_replacers:
|
||||||
@@ -3774,15 +3774,15 @@ class ArchManager(SoftwareManager, SettingsController):
|
|||||||
|
|
||||||
name_priority = dict()
|
name_priority = dict()
|
||||||
|
|
||||||
fill_suggestions = Thread(target=self._fill_suggestions, args=(name_priority,))
|
fill_suggestions = Thread(target=self._fill_suggestions, args=(name_priority,), daemon=True)
|
||||||
fill_suggestions.start()
|
fill_suggestions.start()
|
||||||
|
|
||||||
available_packages = dict()
|
available_packages = dict()
|
||||||
fill_available = Thread(target=self._fill_available_packages, args=(available_packages,))
|
fill_available = Thread(target=self._fill_available_packages, args=(available_packages,), daemon=True)
|
||||||
fill_available.start()
|
fill_available.start()
|
||||||
|
|
||||||
ignored_pkgs = set()
|
ignored_pkgs = set()
|
||||||
fill_ignored = Thread(target=pacman.fill_ignored_packages, args=(ignored_pkgs,))
|
fill_ignored = Thread(target=pacman.fill_ignored_packages, args=(ignored_pkgs,), daemon=True)
|
||||||
fill_ignored.start()
|
fill_ignored.start()
|
||||||
|
|
||||||
fill_suggestions.join()
|
fill_suggestions.join()
|
||||||
@@ -3817,7 +3817,7 @@ class ArchManager(SoftwareManager, SettingsController):
|
|||||||
|
|
||||||
if filter_installed:
|
if filter_installed:
|
||||||
ignored_updates = set()
|
ignored_updates = set()
|
||||||
thread_fill_ignored_updates = Thread(target=self._fill_ignored_updates, args=(ignored_updates,))
|
thread_fill_ignored_updates = Thread(target=self._fill_ignored_updates, args=(ignored_updates,), daemon=True)
|
||||||
thread_fill_ignored_updates.start()
|
thread_fill_ignored_updates.start()
|
||||||
else:
|
else:
|
||||||
ignored_updates, thread_fill_ignored_updates = None, None
|
ignored_updates, thread_fill_ignored_updates = None, None
|
||||||
@@ -3865,7 +3865,7 @@ class ArchManager(SoftwareManager, SettingsController):
|
|||||||
update_ignored=pkg_updates_ignored)
|
update_ignored=pkg_updates_ignored)
|
||||||
|
|
||||||
if disk_loader:
|
if disk_loader:
|
||||||
t = Thread(target=self._fill_cached_if_unset, args=(pkg, disk_loader))
|
t = Thread(target=self._fill_cached_if_unset, args=(pkg, disk_loader), daemon=True)
|
||||||
t.start()
|
t.start()
|
||||||
caching_threads.append(t)
|
caching_threads.append(t)
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ class DependenciesAnalyser:
|
|||||||
|
|
||||||
if not repository:
|
if not repository:
|
||||||
for name in missing_names:
|
for name in missing_names:
|
||||||
t = Thread(target=self._fill_repository, args=(name, missing_root))
|
t = Thread(target=self._fill_repository, args=(name, missing_root), daemon=True)
|
||||||
t.start()
|
t.start()
|
||||||
threads.append(t)
|
threads.append(t)
|
||||||
|
|
||||||
@@ -518,7 +518,8 @@ class DependenciesAnalyser:
|
|||||||
if aur_providers_no_data:
|
if aur_providers_no_data:
|
||||||
aur_providers_data = dict()
|
aur_providers_data = dict()
|
||||||
aur_data_filler = Thread(target=self._fill_aur_updates_data,
|
aur_data_filler = Thread(target=self._fill_aur_updates_data,
|
||||||
args=(aur_providers_no_data, aur_providers_data))
|
args=(aur_providers_no_data, aur_providers_data),
|
||||||
|
daemon=True)
|
||||||
aur_data_filler.start()
|
aur_data_filler.start()
|
||||||
|
|
||||||
if repo_providers_no_data:
|
if repo_providers_no_data:
|
||||||
|
|||||||
@@ -88,7 +88,9 @@ class MultiThreadedDownloader:
|
|||||||
watcher.print("Could not download '{}' from mirror '{}'".format(pkgname, mirror))
|
watcher.print("Could not download '{}' from mirror '{}'".format(pkgname, mirror))
|
||||||
else:
|
else:
|
||||||
self.logger.info("Package '{}' successfully downloaded".format(pkg['n']))
|
self.logger.info("Package '{}' successfully downloaded".format(pkg['n']))
|
||||||
t = Thread(target=self.download_package_signature, args=(pkg, url, output_path, root_password, watcher), daemon=True)
|
t = Thread(target=self.download_package_signature,
|
||||||
|
args=(pkg, url, output_path, root_password, watcher),
|
||||||
|
daemon=True)
|
||||||
t.start()
|
t.start()
|
||||||
self.async_downloads_lock.acquire()
|
self.async_downloads_lock.acquire()
|
||||||
self.async_downloads.append(t)
|
self.async_downloads.append(t)
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ class DebianPackageManager(SoftwareManager, SettingsController):
|
|||||||
|
|
||||||
def search(self, words: str, disk_loader: Optional[DiskCacheLoader], limit: int, is_url: bool) -> SearchResult:
|
def search(self, words: str, disk_loader: Optional[DiskCacheLoader], limit: int, is_url: bool) -> SearchResult:
|
||||||
config_ = dict()
|
config_ = dict()
|
||||||
fill_config = Thread(target=self._fill_config, args=(config_,))
|
fill_config = Thread(target=self._fill_config, args=(config_,), daemon=True)
|
||||||
fill_config.start()
|
fill_config.start()
|
||||||
|
|
||||||
res = SearchResult.empty()
|
res = SearchResult.empty()
|
||||||
@@ -102,11 +102,11 @@ class DebianPackageManager(SoftwareManager, SettingsController):
|
|||||||
names: Optional[Iterable[str]] = None) -> SearchResult:
|
names: Optional[Iterable[str]] = None) -> SearchResult:
|
||||||
|
|
||||||
config_ = dict()
|
config_ = dict()
|
||||||
fill_config = Thread(target=self._fill_config, args=(config_,))
|
fill_config = Thread(target=self._fill_config, args=(config_,), daemon=True)
|
||||||
fill_config.start()
|
fill_config.start()
|
||||||
|
|
||||||
ignored_updates = set()
|
ignored_updates = set()
|
||||||
fill_ignored_updates = Thread(target=self._fill_ignored_updates, args=(ignored_updates,))
|
fill_ignored_updates = Thread(target=self._fill_ignored_updates, args=(ignored_updates,), daemon=True)
|
||||||
fill_ignored_updates.start()
|
fill_ignored_updates.start()
|
||||||
|
|
||||||
threads = (fill_config, fill_ignored_updates)
|
threads = (fill_config, fill_ignored_updates)
|
||||||
@@ -170,7 +170,7 @@ class DebianPackageManager(SoftwareManager, SettingsController):
|
|||||||
if deps:
|
if deps:
|
||||||
# updates are required to be filled in case the dependencies are currently displayed on the view
|
# updates are required to be filled in case the dependencies are currently displayed on the view
|
||||||
updates = dict()
|
updates = dict()
|
||||||
fill_updates = Thread(target=self._fill_updates, args=(updates,))
|
fill_updates = Thread(target=self._fill_updates, args=(updates,), daemon=True)
|
||||||
fill_updates.start()
|
fill_updates.start()
|
||||||
|
|
||||||
deps_data = self.aptitude.show((p.name for p in deps), attrs=('description', 'maintainer', 'section'))
|
deps_data = self.aptitude.show((p.name for p in deps), attrs=('description', 'maintainer', 'section'))
|
||||||
@@ -517,7 +517,7 @@ class DebianPackageManager(SoftwareManager, SettingsController):
|
|||||||
|
|
||||||
def list_updates(self, internet_available: bool) -> List[PackageUpdate]:
|
def list_updates(self, internet_available: bool) -> List[PackageUpdate]:
|
||||||
ignored_updates = set()
|
ignored_updates = set()
|
||||||
fill_ignored_updates = Thread(target=self._fill_ignored_updates, args=(ignored_updates,))
|
fill_ignored_updates = Thread(target=self._fill_ignored_updates, args=(ignored_updates,), daemon=True)
|
||||||
fill_ignored_updates.start()
|
fill_ignored_updates.start()
|
||||||
|
|
||||||
updates = list()
|
updates = list()
|
||||||
@@ -551,7 +551,7 @@ class DebianPackageManager(SoftwareManager, SettingsController):
|
|||||||
|
|
||||||
if filter_installed:
|
if filter_installed:
|
||||||
installed = set()
|
installed = set()
|
||||||
fill_installed = Thread(target=self._fill_installed_names, args=(installed, ))
|
fill_installed = Thread(target=self._fill_installed_names, args=(installed,), daemon=True)
|
||||||
fill_installed.start()
|
fill_installed.start()
|
||||||
else:
|
else:
|
||||||
installed, fill_installed = None, None
|
installed, fill_installed = None, None
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ class FlatpakManager(SoftwareManager, SettingsController):
|
|||||||
for installation in ('system', 'user'):
|
for installation in ('system', 'user'):
|
||||||
runtimes = list()
|
runtimes = list()
|
||||||
output[installation] = runtimes
|
output[installation] = runtimes
|
||||||
t = Thread(target=self._fill_required_runtimes, args=(installation, runtimes))
|
t = Thread(target=self._fill_required_runtimes, args=(installation, runtimes), daemon=True)
|
||||||
t.start()
|
t.start()
|
||||||
threads.append(t)
|
threads.append(t)
|
||||||
|
|
||||||
@@ -150,11 +150,13 @@ class FlatpakManager(SoftwareManager, SettingsController):
|
|||||||
|
|
||||||
thread_updates, thread_runtimes = None, None
|
thread_updates, thread_runtimes = None, None
|
||||||
if internet_available:
|
if internet_available:
|
||||||
thread_updates = Thread(target=self._add_updates, args=(version, updates))
|
thread_updates = Thread(target=self._add_updates, args=(version, updates), daemon=True)
|
||||||
thread_updates.start()
|
thread_updates.start()
|
||||||
|
|
||||||
if version >= VERSION_1_12:
|
if version >= VERSION_1_12:
|
||||||
thread_runtimes = Thread(target=self._fill_required_runtime_updates, args=(required_runtimes,))
|
thread_runtimes = Thread(target=self._fill_required_runtime_updates,
|
||||||
|
args=(required_runtimes,),
|
||||||
|
daemon=True)
|
||||||
thread_runtimes.start()
|
thread_runtimes.start()
|
||||||
|
|
||||||
installed = flatpak.list_installed(version)
|
installed = flatpak.list_installed(version)
|
||||||
@@ -665,7 +667,7 @@ class FlatpakManager(SoftwareManager, SettingsController):
|
|||||||
cached_count += 1
|
cached_count += 1
|
||||||
else:
|
else:
|
||||||
fill = Thread(target=self._fill_suggestion, args=(appid, ids_prios[appid], flatpak_version,
|
fill = Thread(target=self._fill_suggestion, args=(appid, ids_prios[appid], flatpak_version,
|
||||||
remote, res))
|
remote, res), daemon=True)
|
||||||
fill.start()
|
fill.start()
|
||||||
fill_suggestions.append(fill)
|
fill_suggestions.append(fill)
|
||||||
|
|
||||||
|
|||||||
@@ -195,7 +195,7 @@ def list_updates_as_str(version: Tuple[str, ...]) -> Dict[str, Set[str]]:
|
|||||||
|
|
||||||
threads = []
|
threads = []
|
||||||
for type_, output in (('system', sys_updates), ('user', user_updates)):
|
for type_, output in (('system', sys_updates), ('user', user_updates)):
|
||||||
fill = Thread(target=fill_updates, args=(version, type_, output))
|
fill = Thread(target=fill_updates, args=(version, type_, output), daemon=True)
|
||||||
fill.start()
|
fill.start()
|
||||||
threads.append(fill)
|
threads.append(fill)
|
||||||
|
|
||||||
|
|||||||
@@ -434,7 +434,7 @@ class SnapManager(SoftwareManager, SettingsController):
|
|||||||
res.append(cached_sug)
|
res.append(cached_sug)
|
||||||
cached_count += 1
|
cached_count += 1
|
||||||
else:
|
else:
|
||||||
t = Thread(target=self._fill_suggestion, args=(name, ids_prios[name], snapd_client, res))
|
t = Thread(target=self._fill_suggestion, args=(name, ids_prios[name], snapd_client, res), daemon=True)
|
||||||
t.start()
|
t.start()
|
||||||
threads.append(t)
|
threads.append(t)
|
||||||
time.sleep(0.001) # to avoid being blocked
|
time.sleep(0.001) # to avoid being blocked
|
||||||
|
|||||||
@@ -258,7 +258,7 @@ class WebApplicationManager(SoftwareManager, SettingsController):
|
|||||||
|
|
||||||
def search(self, words: str, disk_loader: DiskCacheLoader, limit: int = -1, is_url: bool = False) -> SearchResult:
|
def search(self, words: str, disk_loader: DiskCacheLoader, limit: int = -1, is_url: bool = False) -> SearchResult:
|
||||||
web_config = {}
|
web_config = {}
|
||||||
thread_config = Thread(target=self._fill_config_async, args=(web_config,))
|
thread_config = Thread(target=self._fill_config_async, args=(web_config,), daemon=True)
|
||||||
thread_config.start()
|
thread_config.start()
|
||||||
|
|
||||||
res = SearchResult([], [], 0)
|
res = SearchResult([], [], 0)
|
||||||
@@ -1069,7 +1069,7 @@ class WebApplicationManager(SoftwareManager, SettingsController):
|
|||||||
|
|
||||||
web_config = {}
|
web_config = {}
|
||||||
|
|
||||||
thread_config = Thread(target=self._fill_config_async, args=(web_config,))
|
thread_config = Thread(target=self._fill_config_async, args=(web_config,), daemon=True)
|
||||||
thread_config.start()
|
thread_config.start()
|
||||||
|
|
||||||
if self.suggestions:
|
if self.suggestions:
|
||||||
|
|||||||
@@ -421,11 +421,13 @@ class EnvironmentUpdater:
|
|||||||
if system_env:
|
if system_env:
|
||||||
self.logger.warning(f"Using system's nativefier to install {app.url}")
|
self.logger.warning(f"Using system's nativefier to install {app.url}")
|
||||||
else:
|
else:
|
||||||
node_check = Thread(target=self._check_and_fill_node, args=(env, components))
|
node_check = Thread(target=self._check_and_fill_node, args=(env, components), daemon=True)
|
||||||
node_check.start()
|
node_check.start()
|
||||||
check_threads.append(node_check)
|
check_threads.append(node_check)
|
||||||
|
|
||||||
elec_check = Thread(target=self._check_and_fill_electron, args=(app, env, local_config, is_x86_x64_arch, widevine, components))
|
elec_check = Thread(target=self._check_and_fill_electron,
|
||||||
|
args=(app, env, local_config, is_x86_x64_arch, widevine, components),
|
||||||
|
daemon=True)
|
||||||
elec_check.start()
|
elec_check.start()
|
||||||
check_threads.append(elec_check)
|
check_threads.append(elec_check)
|
||||||
|
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ class GenericSoftwareManager(SoftwareManager, SettingsController):
|
|||||||
|
|
||||||
for man in self.managers:
|
for man in self.managers:
|
||||||
if self._can_work(man):
|
if self._can_work(man):
|
||||||
t = Thread(target=self._search, args=(norm_query, is_url, man, disk_loader, res))
|
t = Thread(target=self._search, args=(norm_query, is_url, man, disk_loader, res), daemon=True)
|
||||||
t.start()
|
t.start()
|
||||||
threads.append(t)
|
threads.append(t)
|
||||||
|
|
||||||
@@ -234,7 +234,9 @@ class GenericSoftwareManager(SoftwareManager, SettingsController):
|
|||||||
disk_loader = self.disk_loader_factory.new()
|
disk_loader = self.disk_loader_factory.new()
|
||||||
disk_loader.start()
|
disk_loader.start()
|
||||||
|
|
||||||
t = Thread(target=self._fill_read_installed, args=(man, disk_loader, net_available, results))
|
t = Thread(target=self._fill_read_installed,
|
||||||
|
args=(man, disk_loader, net_available, results),
|
||||||
|
daemon=True)
|
||||||
t.start()
|
t.start()
|
||||||
read_threads.append(t)
|
read_threads.append(t)
|
||||||
else:
|
else:
|
||||||
@@ -248,7 +250,9 @@ class GenericSoftwareManager(SoftwareManager, SettingsController):
|
|||||||
disk_loader = self.disk_loader_factory.new()
|
disk_loader = self.disk_loader_factory.new()
|
||||||
disk_loader.start()
|
disk_loader.start()
|
||||||
|
|
||||||
t = Thread(target=self._fill_read_installed, args=(man, disk_loader, net_available, results))
|
t = Thread(target=self._fill_read_installed,
|
||||||
|
args=(man, disk_loader, net_available, results),
|
||||||
|
daemon=True)
|
||||||
t.start()
|
t.start()
|
||||||
read_threads.append(t)
|
read_threads.append(t)
|
||||||
|
|
||||||
@@ -510,7 +514,8 @@ class GenericSoftwareManager(SoftwareManager, SettingsController):
|
|||||||
suggestions, threads = [], []
|
suggestions, threads = [], []
|
||||||
for man in self.managers:
|
for man in self.managers:
|
||||||
t = Thread(target=self._fill_suggestions,
|
t = Thread(target=self._fill_suggestions,
|
||||||
args=(suggestions, man, int(self.config['suggestions']['by_type']), filter_installed))
|
args=(suggestions, man, int(self.config['suggestions']['by_type']), filter_installed),
|
||||||
|
daemon=True)
|
||||||
t.start()
|
t.start()
|
||||||
threads.append(t)
|
threads.append(t)
|
||||||
|
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ class AdaptableFileDownloader(FileDownloader):
|
|||||||
msg.write(f' ( {get_human_size_str(known_size)} )')
|
msg.write(f' ( {get_human_size_str(known_size)} )')
|
||||||
watcher.change_substatus(msg.getvalue())
|
watcher.change_substatus(msg.getvalue())
|
||||||
else:
|
else:
|
||||||
Thread(target=self._concat_file_size, args=(file_url, msg, watcher)).start()
|
Thread(target=self._concat_file_size, args=(file_url, msg, watcher), daemon=True).start()
|
||||||
else:
|
else:
|
||||||
msg.write(' ( ? Mb )')
|
msg.write(' ( ? Mb )')
|
||||||
watcher.change_substatus(msg.getvalue())
|
watcher.change_substatus(msg.getvalue())
|
||||||
|
|||||||
@@ -533,14 +533,14 @@ class GenericSettingsManager(SettingsController):
|
|||||||
ti = time.time()
|
ti = time.time()
|
||||||
save_threads, warnings, success_list = [], [], []
|
save_threads, warnings, success_list = [], [], []
|
||||||
|
|
||||||
save_core = Thread(target=self._save_core_settings, args=(component, success_list, warnings))
|
save_core = Thread(target=self._save_core_settings, args=(component, success_list, warnings), daemon=True)
|
||||||
save_core.start()
|
save_core.start()
|
||||||
save_threads.append(save_core)
|
save_threads.append(save_core)
|
||||||
|
|
||||||
if self._settings_views:
|
if self._settings_views:
|
||||||
|
|
||||||
for views in self._settings_views.values():
|
for views in self._settings_views.values():
|
||||||
save_view = Thread(target=self._save_views, args=(views, success_list, warnings))
|
save_view = Thread(target=self._save_views, args=(views, success_list, warnings), daemon=True)
|
||||||
save_view.start()
|
save_view.start()
|
||||||
save_threads.append(save_view)
|
save_threads.append(save_view)
|
||||||
|
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ class TrayIcon(QSystemTrayIcon):
|
|||||||
self.show_manage_window()
|
self.show_manage_window()
|
||||||
|
|
||||||
def verify_updates(self, notify_user: bool = True):
|
def verify_updates(self, notify_user: bool = True):
|
||||||
Thread(target=self._verify_updates, args=(notify_user,)).start()
|
Thread(target=self._verify_updates, args=(notify_user,), daemon=True).start()
|
||||||
|
|
||||||
def _verify_updates(self, notify_user: bool):
|
def _verify_updates(self, notify_user: bool):
|
||||||
self.notify_updates(self.manager.list_updates(), notify_user=notify_user)
|
self.notify_updates(self.manager.list_updates(), notify_user=notify_user)
|
||||||
|
|||||||
Reference in New Issue
Block a user