Session-recovery robustness (from PR #1)

- Suppress ConnectionError log noise from in-flight requests draining
  after a session close (poll_scheduler + keepalive log at DEBUG).
- Null KeepaliveTask.on_unreachable during a forced reconnect so the
  dying session's keepalive can't flip HA availability offline after
  the new session is already healthy. Ported into PR #5's
  _maybe_force_reconnect flow.

Drops the _session_stop / publish-health force-close mechanism from
the original PR — PR #5's last_success_ts + _maybe_force_reconnect
already covers the 'session dead, restart it' goal via a different
path, and running both means two paths force-closing the same session
on the same failure.
This commit is contained in:
Aminorjourney authored and Jack Nagy committed 2026-07-02 21:15:00 +01:00
1 parent 93f78f99a2
commit 015e4a4e9e
4 files changed
+19 -1

No files matched your search

+11 -1
View File
@@ -237,6 +237,11 @@ class PollScheduler:
self.log.warning("poll %s timeout (cooldown %.0fs)",
href, cooldown)
return
except ConnectionError as e:
self._poll_error_count += 1
self._record_rtt((time.monotonic() - t0) * 1000.0)
if self.log: self.log.debug("poll %s: %s", href, e)
return
except Exception as e:
self._poll_error_count += 1
self._record_rtt((time.monotonic() - t0) * 1000.0)
@@ -274,6 +279,11 @@ class PollScheduler:
self.log.warning("sweep %s timeout (cooldown %.0fs)",
path, cooldown)
return
except ConnectionError as e:
self._poll_error_count += 1
self._record_rtt((time.monotonic() - t0) * 1000.0)
if self.log: self.log.debug("sweep %s: %s", path, e)
return
except Exception as e:
self._poll_error_count += 1
self._record_rtt((time.monotonic() - t0) * 1000.0)
@@ -300,4 +310,4 @@ class PollScheduler:
if self.log:
elapsed_ms = (time.monotonic() - t0) * 1000.0
self.log.info("sweep complete (%d links, %.0fms)",
len(indexed), elapsed_ms)
len(indexed), elapsed_ms)