Guard finally blocks against app teardown during Ctrl+C

The sweep/scan finally blocks call self.app.call_from_thread() to
reset button state, but self.app raises NoActiveAppError if the
Textual context is already torn down during Ctrl+C shutdown.
Wrap with contextlib.suppress so the flag reset still happens.
This commit is contained in:
Ryan Malloy 2026-02-14 16:58:21 -07:00
parent c6ac958ee8
commit 972c26b22f

View File

@ -447,6 +447,7 @@ class SignalScreen(Container):
"Firmware sweep failed, falling back to software",
exc_info=True,
)
with contextlib.suppress(Exception):
self.app.call_from_thread(
self._set_sweep_status,
"Firmware sweep failed -- falling back...",
@ -455,6 +456,7 @@ class SignalScreen(Container):
self._do_sweep_software(device)
finally:
self._sweeping = False
with contextlib.suppress(Exception):
self.app.call_from_thread(self._reset_sweep_buttons)
def _do_sweep_firmware(self, device: DeviceLike) -> None:
@ -674,6 +676,7 @@ class SignalScreen(Container):
self._do_scan_inner(device)
finally:
self._scanning = False
with contextlib.suppress(Exception):
self.app.call_from_thread(self._reset_scan_buttons)
def _do_scan_inner(self, device: DeviceLike) -> None: