diff --git a/net_alerter/ble_alerter.py b/net_alerter/ble_alerter.py index d67c689..a84d5ef 100755 --- a/net_alerter/ble_alerter.py +++ b/net_alerter/ble_alerter.py @@ -352,6 +352,10 @@ async def scan_loop(): if "No Bluetooth adapters found" in str(e) or "No default Bluetooth adapter" in str(e): logging.warning("No Bluetooth adapter found — BLE scanning disabled.") shutdown_event.set() + elif "No discovery started" in str(e): + # BlueZ teardown race: SIGTERM cancelled the scanner before BleakScanner.__aexit__ + # ran stop(). BlueZ already stopped the scan, so this is harmless. + logging.debug(f"BlueZ teardown race on shutdown (ignored): {e}") else: logging.error(f"Failed to initialize BLE scanner: {e}") raise