mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 01:14:15 +02:00
[fix][ui] thread waiting error stack
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import faulthandler
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
@@ -14,6 +15,7 @@ def main(tray: bool = False):
|
|||||||
if not os.getenv('PYTHONUNBUFFERED'):
|
if not os.getenv('PYTHONUNBUFFERED'):
|
||||||
os.environ['PYTHONUNBUFFERED'] = '1'
|
os.environ['PYTHONUNBUFFERED'] = '1'
|
||||||
|
|
||||||
|
faulthandler.enable()
|
||||||
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
||||||
|
|
||||||
args = app_args.read()
|
args = app_args.read()
|
||||||
|
|||||||
@@ -772,6 +772,9 @@ class NotifyPackagesReady(QThread):
|
|||||||
self.work = True
|
self.work = True
|
||||||
self.signal_finished.emit()
|
self.signal_finished.emit()
|
||||||
|
|
||||||
|
def stop_working(self):
|
||||||
|
self.work = False
|
||||||
|
|
||||||
|
|
||||||
class NotifyInstalledLoaded(QThread):
|
class NotifyInstalledLoaded(QThread):
|
||||||
signal_loaded = pyqtSignal()
|
signal_loaded = pyqtSignal()
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import datetime
|
||||||
import logging
|
import logging
|
||||||
import operator
|
import operator
|
||||||
import time
|
import time
|
||||||
@@ -100,6 +101,7 @@ class ManageWindow(QWidget):
|
|||||||
signal_user_res = pyqtSignal(bool)
|
signal_user_res = pyqtSignal(bool)
|
||||||
signal_root_password = pyqtSignal(str, bool)
|
signal_root_password = pyqtSignal(str, bool)
|
||||||
signal_table_update = pyqtSignal()
|
signal_table_update = pyqtSignal()
|
||||||
|
signal_stop_notifying = pyqtSignal()
|
||||||
|
|
||||||
def __init__(self, i18n: I18n, icon_cache: MemoryCache, manager: SoftwareManager, screen_size, config: dict,
|
def __init__(self, i18n: I18n, icon_cache: MemoryCache, manager: SoftwareManager, screen_size, config: dict,
|
||||||
context: ApplicationContext, http_client: HttpClient, logger: logging.Logger, icon: QIcon):
|
context: ApplicationContext, http_client: HttpClient, logger: logging.Logger, icon: QIcon):
|
||||||
@@ -376,6 +378,7 @@ class ManageWindow(QWidget):
|
|||||||
self.thread_notify_pkgs_ready = NotifyPackagesReady()
|
self.thread_notify_pkgs_ready = NotifyPackagesReady()
|
||||||
self.thread_notify_pkgs_ready.signal_changed.connect(self._update_package_data)
|
self.thread_notify_pkgs_ready.signal_changed.connect(self._update_package_data)
|
||||||
self.thread_notify_pkgs_ready.signal_finished.connect(self._update_state_when_pkgs_ready)
|
self.thread_notify_pkgs_ready.signal_finished.connect(self._update_state_when_pkgs_ready)
|
||||||
|
self.signal_stop_notifying.connect(self.thread_notify_pkgs_ready.stop_working)
|
||||||
|
|
||||||
self.thread_ignore_updates = IgnorePackageUpdates(manager=self.manager)
|
self.thread_ignore_updates = IgnorePackageUpdates(manager=self.manager)
|
||||||
self._bind_async_action(self.thread_ignore_updates, finished_call=self.finish_ignore_updates)
|
self._bind_async_action(self.thread_ignore_updates, finished_call=self.finish_ignore_updates)
|
||||||
@@ -486,8 +489,7 @@ class ManageWindow(QWidget):
|
|||||||
self.table_container.setCursor(QCursor(Qt.WaitCursor))
|
self.table_container.setCursor(QCursor(Qt.WaitCursor))
|
||||||
|
|
||||||
def begin_apply_filters(self):
|
def begin_apply_filters(self):
|
||||||
self.thread_notify_pkgs_ready.work = False
|
self.stop_notifying_package_states()
|
||||||
self.thread_notify_pkgs_ready.wait(5)
|
|
||||||
self._begin_action(action_label=self.i18n['manage_window.status.filtering'],
|
self._begin_action(action_label=self.i18n['manage_window.status.filtering'],
|
||||||
action_id=ACTION_APPLY_FILTERS)
|
action_id=ACTION_APPLY_FILTERS)
|
||||||
self.comp_manager.disable_visible_from_groups(GROUP_UPPER_BAR, GROUP_LOWER_BTS)
|
self.comp_manager.disable_visible_from_groups(GROUP_UPPER_BAR, GROUP_LOWER_BTS)
|
||||||
@@ -502,13 +504,22 @@ class ManageWindow(QWidget):
|
|||||||
self._finish_action(ACTION_APPLY_FILTERS)
|
self._finish_action(ACTION_APPLY_FILTERS)
|
||||||
self.update_bt_upgrade()
|
self.update_bt_upgrade()
|
||||||
|
|
||||||
|
def stop_notifying_package_states(self):
|
||||||
|
if self.thread_notify_pkgs_ready.isRunning():
|
||||||
|
self.signal_stop_notifying.emit()
|
||||||
|
|
||||||
|
expires_at = datetime.datetime.now() + datetime.timedelta(seconds=5)
|
||||||
|
|
||||||
|
while datetime.datetime.now() < expires_at and self.thread_notify_pkgs_ready.isRunning():
|
||||||
|
time.sleep(0.1)
|
||||||
|
|
||||||
def _update_table_and_upgrades(self, pkgs_info: dict):
|
def _update_table_and_upgrades(self, pkgs_info: dict):
|
||||||
self._update_table(pkgs_info=pkgs_info, signal=True)
|
self._update_table(pkgs_info=pkgs_info, signal=True)
|
||||||
|
|
||||||
if self.pkgs:
|
if self.pkgs:
|
||||||
self._update_state_when_pkgs_ready()
|
self._update_state_when_pkgs_ready()
|
||||||
self.thread_notify_pkgs_ready.work = False
|
|
||||||
self.thread_notify_pkgs_ready.wait(5)
|
self.stop_notifying_package_states()
|
||||||
self.thread_notify_pkgs_ready.pkgs = self.pkgs
|
self.thread_notify_pkgs_ready.pkgs = self.pkgs
|
||||||
self.thread_notify_pkgs_ready.work = True
|
self.thread_notify_pkgs_ready.work = True
|
||||||
self.thread_notify_pkgs_ready.start()
|
self.thread_notify_pkgs_ready.start()
|
||||||
@@ -943,6 +954,8 @@ class ManageWindow(QWidget):
|
|||||||
self._update_table(pkgs_info=pkgs_info)
|
self._update_table(pkgs_info=pkgs_info)
|
||||||
|
|
||||||
if new_pkgs:
|
if new_pkgs:
|
||||||
|
self.stop_notifying_package_states()
|
||||||
|
self.thread_notify_pkgs_ready.work = True
|
||||||
self.thread_notify_pkgs_ready.pkgs = self.pkgs
|
self.thread_notify_pkgs_ready.pkgs = self.pkgs
|
||||||
self.thread_notify_pkgs_ready.start()
|
self.thread_notify_pkgs_ready.start()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user