diff --git a/net_alerter/net_alerter.py b/net_alerter/net_alerter.py index 9c819e6..a090ca4 100644 --- a/net_alerter/net_alerter.py +++ b/net_alerter/net_alerter.py @@ -1787,15 +1787,14 @@ def personal_watchdog() -> None: # Check if device is silent if now - ts > WATCHDOG_TIMEOUT_SEC: # Only fire if device is currently known and not already departing - # Don't hold lock when calling on_departure + should_depart = False with known_lock: if mac in known_devices and not known_devices[mac].get('departing'): - # Copy the device info before releasing lock - dev_info = known_devices[mac].copy() - - # Fire departure outside the lock - logging.info(f"Watchdog: personal device {mac} silent >{WATCHDOG_TIMEOUT_SEC}s, triggering departure") - on_departure(mac) + should_depart = True + + if should_depart: + logging.info(f"Watchdog: personal device {mac} silent >{WATCHDOG_TIMEOUT_SEC}s, triggering departure") + on_departure(mac) except Exception as e: logging.error(f"Watchdog thread error: {e}")