🚧 virtual: Better error handling & identifier

This commit is contained in:
Gina Häußge committed 2021-07-02 16:16:49 +02:00
1 parent 11047940bc
commit 8ff0eab24e
2 files changed
+14 -8

No files matched your search

@@ -193,6 +193,14 @@ class VirtualPrinterPlugin(
print(f"<<< {received.rstrip()}")
self.incoming.put(received)
except ConnectionAbortedError:
self.close()
except ValueError as ex:
self.close()
if "file descriptor cannot be a negative number" in str(ex):
pass
else:
raise
except Exception:
self.close()
raise
@@ -228,14 +236,10 @@ class VirtualPrinterPlugin(
return self._socket.recv(size)
def _do_write(self, data):
try:
ready = select.select([], [self._socket], [], 10)
if self._socket not in ready[1]:
raise socket.timeout()
self._socket.sendall(data)
except Exception:
self.close()
raise
ready = select.select([], [self._socket], [], 10)
if self._socket not in ready[1]:
raise socket.timeout()
self._socket.sendall(data)
##~~ TCP Socket
@@ -705,6 +705,8 @@ class VirtualPrinter:
for cap, enabled in self._capabilities.items():
self._send("Cap:{}:{}".format(cap.upper(), "1" if enabled else "0"))
self._send("echo:OctoPrint Virtual Printer reporting for duty")
def _gcode_M117(self, data: str) -> None:
# we'll just use this to echo a message, to allow playing around with pause triggers
if self._echoOnM117: