From 2e897f19accef98deaefdf0d09bf93005576d7e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Fri, 7 Jul 2017 15:56:22 +0200 Subject: [PATCH] Synchronize all writing access to the send queue --- src/octoprint/util/comm.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index 1ed32665..3517b970 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -2240,16 +2240,17 @@ class MachineCom(object): continue if len(results) > 1: - # last command gets on_sent attached - last = results[-1] - self._send_queue.prepend((last[0], None, None, on_sent, True)) - on_sent = None + with self._sendingLock: + # last command gets on_sent attached + last = results[-1] + self._send_queue.prepend((last[0], None, None, on_sent, True)) + on_sent = None - # middle gets prepended reversed (so order gets restored) - if len(results) > 2: - to_prepend = reversed(results[1:-1]) - for m in to_prepend: - self._send_queue.prepend((m[0], None, None, None, True)) + # middle gets prepended reversed (so order gets restored) + if len(results) > 2: + to_prepend = reversed(results[1:-1]) + for m in to_prepend: + self._send_queue.prepend((m[0], None, None, None, True)) # we only actually send the first entry here command, _, gcode, subcode = results[0]