From aea36c9bfbfbb146809847d095b9d452865acce6 Mon Sep 17 00:00:00 2001 From: Ioannis Mourginakis Date: Fri, 6 Oct 2023 11:47:50 -0700 Subject: [PATCH] add error handling for NodeMonitor.step() --- node_monitor/node_monitor.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/node_monitor/node_monitor.py b/node_monitor/node_monitor.py index 2afd4324..c29cae51 100644 --- a/node_monitor/node_monitor.py +++ b/node_monitor/node_monitor.py @@ -151,9 +151,14 @@ def broadcast_status_report(self) -> None: def step(self) -> None: """Iterate NodeMonitor one step.""" - self._resync() - self._analyze() - self.broadcast_alerts() + try: + # These all need to be in the same try/catch block, because if + # _resync fails, we don't want to analyze or broadcast_alerts. + self._resync() + self._analyze() + self.broadcast_alerts() + except Exception as e: + print(f"NodeMonitor.step() failed with error: {e}") def mainloop(self) -> None: