mirror of https://github.com/Desuuuu/klipper.git
klippy: Add an is_shutdown() method
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
86a99cf38e
commit
44f868a802
|
@ -54,7 +54,7 @@ class Printer:
|
|||
self.reactor = reactor.Reactor()
|
||||
self.reactor.register_callback(self._connect)
|
||||
self.state_message = message_startup
|
||||
self.is_shutdown = False
|
||||
self.in_shutdown_state = False
|
||||
self.run_result = None
|
||||
self.event_handlers = {}
|
||||
gc = gcode.GCodeParser(self, input_fd)
|
||||
|
@ -65,6 +65,8 @@ class Printer:
|
|||
return self.reactor
|
||||
def get_state_message(self):
|
||||
return self.state_message
|
||||
def is_shutdown(self):
|
||||
return self.in_shutdown_state
|
||||
def _set_state(self, msg):
|
||||
if self.state_message in (message_ready, message_startup):
|
||||
self.state_message = msg
|
||||
|
@ -188,10 +190,10 @@ class Printer:
|
|||
logging.exception("Unhandled exception during post run")
|
||||
return run_result
|
||||
def invoke_shutdown(self, msg):
|
||||
if self.is_shutdown:
|
||||
if self.in_shutdown_state:
|
||||
return
|
||||
logging.error("Transition to shutdown state: %s", msg)
|
||||
self.is_shutdown = True
|
||||
self.in_shutdown_state = True
|
||||
self._set_state("%s%s" % (msg, message_shutdown))
|
||||
for cb in self.event_handlers.get("klippy:shutdown", []):
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue