diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2018-02-02 18:28:48 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2018-02-02 18:32:03 -0500 |
commit | 0b7686445376ace8a32c729d05c690818b319b29 (patch) | |
tree | 91aa04a831e814d7b414d5b6b210cba7eb4b3e91 /klippy/gcode.py | |
parent | 56bfb3280a756ff4f71de258e37f6e230d4292d2 (diff) | |
download | kutter-0b7686445376ace8a32c729d05c690818b319b29.tar.gz kutter-0b7686445376ace8a32c729d05c690818b319b29.tar.xz kutter-0b7686445376ace8a32c729d05c690818b319b29.zip |
gcode: Make sure need_ack is always restored on run_script()
Restore need_ack even on a G-Code exception.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/gcode.py')
-rw-r--r-- | klippy/gcode.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/klippy/gcode.py b/klippy/gcode.py index 38ff348a..21a27252 100644 --- a/klippy/gcode.py +++ b/klippy/gcode.py @@ -135,7 +135,6 @@ class GCodeParser: # Parse input into commands args_r = re.compile('([A-Z_]+|[A-Z*])') def process_commands(self, commands, need_ack=True): - prev_need_ack = self.need_ack for line in commands: # Ignore comments and leading/trailing spaces line = origline = line.strip() @@ -172,7 +171,6 @@ class GCodeParser: if not need_ack: raise self.ack() - self.need_ack = prev_need_ack m112_r = re.compile('^(?:[nN][0-9]+)?\s*[mM]112(?:\s|$)') def process_data(self, eventtime): # Read input, separate by newline, and add to pending_commands @@ -213,7 +211,11 @@ class GCodeParser: self.toolhead.wait_moves() self.printer.request_exit() def run_script(self, script): - self.process_commands(script.split('\n'), need_ack=False) + prev_need_ack = self.need_ack + try: + self.process_commands(script.split('\n'), need_ack=False) + finally: + self.need_ack = prev_need_ack # Response handling def ack(self, msg=None): if not self.need_ack or self.is_fileinput: |