Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

fix(watchdog): never report a stopped event loop as stalled (#523)

Ruben Lütke69731c291ad7
diff --git a/jarvis/core/loop_watchdog.py b/jarvis/core/loop_watchdog.py
index b6da55fea0..f91cd0547b 100644
--- a/jarvis/core/loop_watchdog.py
+++ b/jarvis/core/loop_watchdog.py
@@ -147,6 +147,12 @@ class EventLoopWatchdog:
if silent_for < self._stall_s:
continue
+ # A wedged loop is still running inside one callback. A loop that
+ # is stopping or not started yet runs nothing, which is no stall.
+ if self._loop.is_closed():
+ return
+ if not self._loop.is_running():
+ continue
now = time.monotonic()
if reported_at is not None and now - reported_at < self._repeat_s:
continue
diff --git a/tests/fakes/fake_watchdog_clock.py b/tests/fakes/fake_watchdog_clock.py
index e47b945c98..4da9e87a63 100644
--- a/tests/fakes/fake_watchdog_clock.py
+++ b/tests/fakes/fake_watchdog_clock.py
@@ -18,6 +18,13 @@ class ScriptedWatchdogClock:
def call_soon_threadsafe(self, callback: Callable[[], None]) -> None:
self._pending.append(callback)
+ def is_running(self) -> bool:
+ # A stalled loop is still running; it is stuck inside one callback.
+ return True
+
+ def is_closed(self) -> bool:
+ return False
+
def is_set(self) -> bool:
return self._index == len(self._ticks)