From 1039191fe2643ee13a6a09ee9e4f360d667b01c9 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Tue, 26 Aug 2025 02:01:42 -0700 Subject: [PATCH] always run signal handler and store callbacks, like qt --- system/ui/lib/wifi_manager.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/system/ui/lib/wifi_manager.py b/system/ui/lib/wifi_manager.py index f71a342ddb..dedd322608 100644 --- a/system/ui/lib/wifi_manager.py +++ b/system/ui/lib/wifi_manager.py @@ -196,26 +196,17 @@ class WifiManager: with self._conn_monitor.filter(rule, bufsize=SIGNAL_QUEUE_SIZE) as q: while not self._exit: - # TODO: always run, and ensure callbacks don't block UI thread - if not self._active: - time.sleep(1) - continue - # Block until a matching signal arrives try: msg = self._conn_monitor.recv_until_filtered(q, timeout=1) + new_state, previous_state, change_reason = msg.body except TimeoutError: continue - new_state, previous_state, change_reason = msg.body - # BAD PASSWORD if new_state == NMDeviceState.NEED_AUTH and change_reason == NM_DEVICE_STATE_REASON_SUPPLICANT_DISCONNECT and len(self._connecting_to_ssid): self.forget_connection(self._connecting_to_ssid, block=True) - print('hi') if self._need_auth is not None: - print('wifi need auth', self._connecting_to_ssid) - # self._callback_queue.append(lambda cb=self._need_auth, ssid=self._connecting_to_ssid: cb(ssid)) self._enqueue_callback(self._need_auth, self._connecting_to_ssid) self._connecting_to_ssid = "" @@ -376,6 +367,10 @@ class WifiManager: cloudlog.warning("No WiFi device found") return + if not self._active: + cloudlog.debug("Skipping network update, not active") + return + # returns '/' if no active AP wifi_addr = DBusAddress(self._wifi_device, NM, interface=NM_WIRELESS_IFACE) active_ap_path = self._router_main.send_and_get_reply(Properties(wifi_addr).get('ActiveAccessPoint')).body[0][1]