From a04e91c046ea34c671fc4bf4414933fedab1ad81 Mon Sep 17 00:00:00 2001 From: Eric Callahan Date: Sat, 5 Feb 2022 20:24:00 -0500 Subject: [PATCH] proc_stats: track the loop blocked count Signed-off-by: Eric Callahan --- moonraker/components/proc_stats.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/moonraker/components/proc_stats.py b/moonraker/components/proc_stats.py index b7bed48..b848faf 100644 --- a/moonraker/components/proc_stats.py +++ b/moonraker/components/proc_stats.py @@ -282,6 +282,7 @@ class Watchdog: def __init__(self, proc_stats: ProcStats) -> None: self.proc_stats = proc_stats self.event_loop = proc_stats.event_loop + self.blocked_count: int = 0 self.last_watch_time: float = 0. self.watchdog_timer = self.event_loop.register_timer( self._watchdog_callback @@ -290,8 +291,10 @@ class Watchdog: def _watchdog_callback(self, eventtime: float) -> float: time_diff = eventtime - self.last_watch_time if time_diff > REPORT_BLOCKED_TIME: + self.blocked_count += 1 logging.info( - f"EVENT LOOP BLOCKED: {round(time_diff, 2)} seconds") + f"EVENT LOOP BLOCKED: {round(time_diff, 2)} seconds" + f", total blocked count: {self.blocked_count}") # delay the stat logging so we capture the CPU percentage after # the next cycle self.event_loop.delay_callback(