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:
parent
c6ac958ee8
commit
972c26b22f
@ -447,15 +447,17 @@ class SignalScreen(Container):
|
|||||||
"Firmware sweep failed, falling back to software",
|
"Firmware sweep failed, falling back to software",
|
||||||
exc_info=True,
|
exc_info=True,
|
||||||
)
|
)
|
||||||
self.app.call_from_thread(
|
with contextlib.suppress(Exception):
|
||||||
self._set_sweep_status,
|
self.app.call_from_thread(
|
||||||
"Firmware sweep failed -- falling back...",
|
self._set_sweep_status,
|
||||||
)
|
"Firmware sweep failed -- falling back...",
|
||||||
|
)
|
||||||
|
|
||||||
self._do_sweep_software(device)
|
self._do_sweep_software(device)
|
||||||
finally:
|
finally:
|
||||||
self._sweeping = False
|
self._sweeping = False
|
||||||
self.app.call_from_thread(self._reset_sweep_buttons)
|
with contextlib.suppress(Exception):
|
||||||
|
self.app.call_from_thread(self._reset_sweep_buttons)
|
||||||
|
|
||||||
def _do_sweep_firmware(self, device: DeviceLike) -> None:
|
def _do_sweep_firmware(self, device: DeviceLike) -> None:
|
||||||
"""Firmware-accelerated sweep via azscanwxp (runs in worker thread)."""
|
"""Firmware-accelerated sweep via azscanwxp (runs in worker thread)."""
|
||||||
@ -674,7 +676,8 @@ class SignalScreen(Container):
|
|||||||
self._do_scan_inner(device)
|
self._do_scan_inner(device)
|
||||||
finally:
|
finally:
|
||||||
self._scanning = False
|
self._scanning = False
|
||||||
self.app.call_from_thread(self._reset_scan_buttons)
|
with contextlib.suppress(Exception):
|
||||||
|
self.app.call_from_thread(self._reset_scan_buttons)
|
||||||
|
|
||||||
def _do_scan_inner(self, device: DeviceLike) -> None:
|
def _do_scan_inner(self, device: DeviceLike) -> None:
|
||||||
"""Inner scan logic (called from _do_scan worker thread)."""
|
"""Inner scan logic (called from _do_scan worker thread)."""
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user