mirror of
https://github.com/Klipper3d/klipper.git
synced 2025-10-26 00:36:08 +02:00
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 <kevin@koconnor.net>
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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)))
|
||||
|
||||
Reference in New Issue
Block a user