From f147804d97180d486fc6591c2663f3d5562fd499 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Wed, 8 Oct 2025 13:15:07 -0400 Subject: [PATCH] error_mcu: Rename "klippy:notify_mcu_shutdown" to "klippy:analyze_shutdown" Rename the event to make it a little more clear what it is intended for. Also, check for an exception in each event handler. Signed-off-by: Kevin O'Connor --- klippy/extras/error_mcu.py | 6 +++--- klippy/klippy.py | 6 +++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/klippy/extras/error_mcu.py b/klippy/extras/error_mcu.py index dc91c33a9..d30fcf2cf 100644 --- a/klippy/extras/error_mcu.py +++ b/klippy/extras/error_mcu.py @@ -62,8 +62,8 @@ class PrinterMCUError: def __init__(self, config): self.printer = config.get_printer() self.clarify_callbacks = {} - self.printer.register_event_handler("klippy:notify_mcu_shutdown", - self._handle_notify_mcu_shutdown) + self.printer.register_event_handler("klippy:analyze_shutdown", + self._handle_analyze_shutdown) self.printer.register_event_handler("klippy:notify_mcu_error", self._handle_notify_mcu_error) def add_clarify(self, msg, callback): @@ -88,7 +88,7 @@ class PrinterMCUError: newmsg = "%s%s%s%s%s" % (prefix, mcu_msg, clarify_msg, hint, message_shutdown) self.printer.update_error_msg(msg, newmsg) - def _handle_notify_mcu_shutdown(self, msg, details): + def _handle_analyze_shutdown(self, msg, details): if msg == "MCU shutdown": self._check_mcu_shutdown(msg, details) else: diff --git a/klippy/klippy.py b/klippy/klippy.py index 1d3ffbf06..a4bfd08c0 100644 --- a/klippy/klippy.py +++ b/klippy/klippy.py @@ -213,7 +213,11 @@ class Printer: logging.exception("Exception during shutdown handler") logging.info("Reactor garbage collection: %s", self.reactor.get_gc_stats()) - self.send_event("klippy:notify_mcu_shutdown", msg, details) + for cb in self.event_handlers.get("klippy:analyze_shutdown", []): + try: + cb(msg, details) + except: + logging.exception("Exception during analyze_shutdown handler") def invoke_async_shutdown(self, msg, details={}): self.reactor.register_async_callback( (lambda e: self.invoke_shutdown(msg, details)))