From fb27d5ba6442fded66cdec3fbc5275303de5e730 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 28 Nov 2023 11:27:08 +0100 Subject: [PATCH 1/4] =?UTF-8?q?=F0=9F=A5=85=20virtual:=20recalculate=20wai?= =?UTF-8?q?t=20timeout=20after=20gcode=20eval?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise we might run into a race condition in case of long running commands. For an example see #4907: A `G4 S54` triggered a `wait` response, since right after sending the `ok` the host didn't send a new incoming line fast enough to prevent that from happening. As a result, combined with several simulated transmition errors right after, things get so much out of balance that at some point the incoming queue runs full and an exception gets triggered, killing the connection with a simulated SerialTimeout. This fix should close the core cause of #4907 --- .../plugins/virtual_printer/virtual.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/octoprint/plugins/virtual_printer/virtual.py b/src/octoprint/plugins/virtual_printer/virtual.py index fba3678cd..dc0e3c74a 100644 --- a/src/octoprint/plugins/virtual_printer/virtual.py +++ b/src/octoprint/plugins/virtual_printer/virtual.py @@ -345,7 +345,14 @@ class VirtualPrinter: pass def _processIncoming(self): - next_wait_timeout = time.monotonic() + self._waitInterval + next_wait_timeout = 0 + + def recalculate_next_wait_timeout(): + nonlocal next_wait_timeout + next_wait_timeout = time.monotonic() + self._waitInterval + + recalculate_next_wait_timeout() + buf = b"" while self.incoming is not None and not self._killed: self._simulateTemps() @@ -361,7 +368,7 @@ class VirtualPrinter: except queue.Empty: if self._sendWait and time.monotonic() > next_wait_timeout: self._send("wait") - next_wait_timeout = time.monotonic() + self._waitInterval + recalculate_next_wait_timeout() continue except Exception: if self.incoming is None: @@ -377,7 +384,7 @@ class VirtualPrinter: else: continue - next_wait_timeout = time.monotonic() + self._waitInterval + recalculate_next_wait_timeout() if data is None: continue @@ -527,6 +534,10 @@ class VirtualPrinter: continue finally: + # recalculate the timeout again, as we might have just run a long + # running command + recalculate_next_wait_timeout() + # make sure that the debug sleepAfter and sleepAfterNext stuff works even # if we continued above if len(self._sleepAfter) or len(self._sleepAfterNext): From 734ce07913b8c7e22d1c26613cae208bdc02ef18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 28 Nov 2023 17:41:42 +0100 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=90=9B=20discovery:=20fix=20ssdp=20on?= =?UTF-8?q?=20vlans?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Really listen on ALL configured addresses, not just the first one per device. Closes #4814 Thanks @nastevens! --- src/octoprint/plugins/discovery/__init__.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/octoprint/plugins/discovery/__init__.py b/src/octoprint/plugins/discovery/__init__.py index 62f07de93..d6033f618 100644 --- a/src/octoprint/plugins/discovery/__init__.py +++ b/src/octoprint/plugins/discovery/__init__.py @@ -703,12 +703,13 @@ class DiscoveryPlugin( sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 2) sock.bind(("", self.__class__.ssdp_multicast_port)) - sock.setsockopt( - socket.IPPROTO_IP, - socket.IP_ADD_MEMBERSHIP, - socket.inet_aton(self.__class__.ssdp_multicast_addr) - + socket.inet_aton("0.0.0.0"), - ) + for address in self.get_interface_addresses(): + sock.setsockopt( + socket.IPPROTO_IP, + socket.IP_ADD_MEMBERSHIP, + socket.inet_aton(self.__class__.ssdp_multicast_addr) + + socket.inet_aton(address), + ) self._logger.info(f"Registered {self.get_instance_name()} for SSDP") From 6a75fb6c34851b85d41196d2c876c689ac082b80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 28 Nov 2023 18:09:23 +0100 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=9A=B8=20Keep=20tool=20change=20contr?= =?UTF-8?q?ol=20enabled=20while=20printing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implements #4892 --- src/octoprint/templates/tabs/control.jinja2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/octoprint/templates/tabs/control.jinja2 b/src/octoprint/templates/tabs/control.jinja2 index 65dc3adaf..258497d0d 100644 --- a/src/octoprint/templates/tabs/control.jinja2 +++ b/src/octoprint/templates/tabs/control.jinja2 @@ -120,12 +120,12 @@
-
From 6349ce88c4ea2b80d97e8bad4048995f14f2ce0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 28 Nov 2023 18:09:42 +0100 Subject: [PATCH 4/4] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20Upgrade=20zeroconf?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 5f3c0f6de..f67b31d70 100644 --- a/setup.py +++ b/setup.py @@ -71,7 +71,7 @@ core_deps = [ "websocket-client>=1.5.1,<2", "werkzeug>=2.2.3,<2.3", # breaking changes can happen on minor version increases "wrapt>=1.15,<1.16", - "zeroconf==0.39.4", # final version to include universal wheel, later takes ages to compiles on rpi, piwheels has no wheels for latest either + "zeroconf~=0.127", # breaking changes can happen on minor version increases (despite semantic versioning) "zipstream-ng>=1.5.0,<2.0.0", ] vendored_deps = [