mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-10-05 06:45:09 +00:00
feat(ipc): control socket stage 3 - a state stream replaces polled cache keys (#735)
Adds state.get / state.subscribe to the display's control socket (StateHub in src/ipc/server.py). The web interface holds one subscription per process (web_interface/display_state.py) and reads current-status, on-demand status, plugin runtime and /health's display_loop from it, falling back to the cache keys and heartbeat file. While the socket serves readers, display_current_state and plugin_runtime_snapshot are written less often (about 1.5 instead of 5 cache writes a minute for 15 s screens). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -216,6 +216,23 @@ class RenderWatchdog:
|
||||
def armed(self) -> bool:
|
||||
return self._armed
|
||||
|
||||
def liveness(self) -> Dict[str, Any]:
|
||||
"""The heartbeat, in memory: what the control socket's state stream
|
||||
reports as ``loop``.
|
||||
|
||||
``heartbeat_age_seconds`` is the age of the render thread's last beat,
|
||||
the beat that writes the heartbeat file, so it ages at the same rate
|
||||
and is judged by the same ``HEARTBEAT_STALE_SECONDS``. None until the
|
||||
loop has drawn its first frame. Any thread may call this: it only
|
||||
reads two attributes.
|
||||
"""
|
||||
last = self._last_beat
|
||||
age = None
|
||||
if self._armed and last is not None:
|
||||
age = max(self._clock() - last, 0.0)
|
||||
return {'heartbeat_age_seconds': age, 'armed': self._armed,
|
||||
'stale_after': HEARTBEAT_STALE_SECONDS}
|
||||
|
||||
def _on_render_thread(self) -> bool:
|
||||
return self._render_thread is not None and threading.get_ident() == self._render_thread
|
||||
|
||||
|
||||
Reference in New Issue
Block a user