From a5e55c2acc2650c70acd6bf852810e30fb959f96 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Thu, 18 Oct 2018 11:51:35 -0400 Subject: gcode: process_batch() should execute commands atomically Update the process_batch() method so that it will not interleave commands read from the input fd with the batched commands. Signed-off-by: Kevin O'Connor --- klippy/extras/idle_timeout.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'klippy/extras/idle_timeout.py') diff --git a/klippy/extras/idle_timeout.py b/klippy/extras/idle_timeout.py index 7ead83e2..39563b12 100644 --- a/klippy/extras/idle_timeout.py +++ b/klippy/extras/idle_timeout.py @@ -15,7 +15,7 @@ class IdleTimeout: self.toolhead = None self.last_timeout = 0. self.idle_timeout = config.getfloat('timeout', 600., above=0.) - self.idle_script = config.get('gcode', DEFAULT_IDLE_GCODE) + self.idle_gcode = config.get('gcode', DEFAULT_IDLE_GCODE).split('\n') def printer_state(self, state): if state == 'ready': self.toolhead = self.printer.lookup_object('toolhead') @@ -23,14 +23,14 @@ class IdleTimeout: reactor.register_timer(self.timeout_handler, reactor.NOW) def run_idle_script(self): gcode = self.printer.lookup_object('gcode') - for line in self.idle_script.split('\n'): - try: - res = gcode.process_batch(line) - except: - break - if not res: - # Raced with incoming g-code commands - return + try: + res = gcode.process_batch(self.idle_gcode) + except: + logging.exception("idle timeout gcode execution") + return + if not res: + # Raced with incoming g-code commands + return self.last_timeout = self.toolhead.get_last_move_time() def timeout_handler(self, eventtime): info = self.toolhead.get_status(eventtime) -- cgit v1.2.3-70-g09d2