From 26383658390012425c1982cf88b2a573fe359f2c Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 12 Oct 2016 14:36:41 +0200 Subject: [PATCH 1/6] LastRequestTime is reset on connection close CURA-2630 --- NetworkPrinterOutputDevice.py | 1 + 1 file changed, 1 insertion(+) diff --git a/NetworkPrinterOutputDevice.py b/NetworkPrinterOutputDevice.py index 2eb126d966..a1bb52c514 100644 --- a/NetworkPrinterOutputDevice.py +++ b/NetworkPrinterOutputDevice.py @@ -464,6 +464,7 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): # Reset timeout state self._connection_state_before_timeout = None self._last_response_time = time() + self._last_request_time = None # Stop update timers self._update_timer.stop() From a9b45572cc0343ee3f83353bf92d3cacc7dfcfb7 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 12 Oct 2016 14:50:58 +0200 Subject: [PATCH 2/6] PostReply is now always reset correctly CURA-2630 --- NetworkPrinterOutputDevice.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/NetworkPrinterOutputDevice.py b/NetworkPrinterOutputDevice.py index a1bb52c514..2fd433775f 100644 --- a/NetworkPrinterOutputDevice.py +++ b/NetworkPrinterOutputDevice.py @@ -631,6 +631,7 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): self._compressing_print = False if self._post_reply: self._post_reply.abort() + self._post_reply = None Application.getInstance().showPrintMonitor.emit(False) ## Attempt to start a new print. @@ -747,6 +748,7 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): self._post_reply.abort() self._post_reply.uploadProgress.disconnect(self._onUploadProgress) Logger.log("d", "Uploading of print failed after %s", time() - self._send_gcode_start) + self._post_reply = None self._progress_message.hide() self.setConnectionState(ConnectionState.error) @@ -901,6 +903,9 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): elif "print_job" in reply_url: reply.uploadProgress.disconnect(self._onUploadProgress) Logger.log("d", "Uploading of print succeeded after %s", time() - self._send_gcode_start) + # Only reset the _post_reply if it was the same one. + if reply == self._post_reply: + self._post_reply = None self._progress_message.hide() elif reply.operation() == QNetworkAccessManager.PutOperation: From 2337a78a71e36386a687f8e8a7f0be0703ea45ba Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 12 Oct 2016 15:08:23 +0200 Subject: [PATCH 3/6] Camera requests now also set last_request_time CURA-2630 --- NetworkPrinterOutputDevice.py | 1 + 1 file changed, 1 insertion(+) diff --git a/NetworkPrinterOutputDevice.py b/NetworkPrinterOutputDevice.py index 2fd433775f..934092f33c 100644 --- a/NetworkPrinterOutputDevice.py +++ b/NetworkPrinterOutputDevice.py @@ -230,6 +230,7 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): url = QUrl("http://" + self._address + ":8080/?action=snapshot") image_request = QNetworkRequest(url) self._manager.get(image_request) + self._last_request_time = time() ## Set the authentication state. # \param auth_state \type{AuthState} Enum value representing the new auth state From 91521eb49d1e6c0664fdc98b944d0e09e961535b Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 12 Oct 2016 16:02:35 +0200 Subject: [PATCH 4/6] Added logging if connection to network printer was closed CURA-2630 --- NetworkPrinterOutputDevice.py | 1 + 1 file changed, 1 insertion(+) diff --git a/NetworkPrinterOutputDevice.py b/NetworkPrinterOutputDevice.py index 934092f33c..2581a4c3ca 100644 --- a/NetworkPrinterOutputDevice.py +++ b/NetworkPrinterOutputDevice.py @@ -440,6 +440,7 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): def close(self): + Logger.log("d", "Closing connection of printer %s with ip %s", self._key, self._address) self._updateJobState("") self.setConnectionState(ConnectionState.closed) if self._progress_message: From dc34b898d46da7af94ac2ad368fac7d9c0c70249 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 12 Oct 2016 16:35:22 +0200 Subject: [PATCH 5/6] Added max recreateNetworkManager count increase per update CURA-2630 --- NetworkPrinterOutputDevice.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/NetworkPrinterOutputDevice.py b/NetworkPrinterOutputDevice.py index 2581a4c3ca..ac3af93c84 100644 --- a/NetworkPrinterOutputDevice.py +++ b/NetworkPrinterOutputDevice.py @@ -314,9 +314,11 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): if self._last_response_time and self._connection_state_before_timeout: if time_since_last_response > self._recreate_network_manager_time * self._recreate_network_manager_count: self._recreate_network_manager_count += 1 + counter = 0 # Counter to prevent possible indefinite while loop. # It can happen that we had a very long timeout (multiple times the recreate time). # In that case we should jump through the point that the next update won't be right away. - while time_since_last_response - self._recreate_network_manager_time * self._recreate_network_manager_count > self._recreate_network_manager_time: + while time_since_last_response - self._recreate_network_manager_time * self._recreate_network_manager_count > self._recreate_network_manager_time and counter < 10: + counter += 1 self._recreate_network_manager_count += 1 Logger.log("d", "Timeout lasted over 30 seconds (%.1fs), re-checking connection.", time_since_last_response) self._createNetworkManager() From 8951efd140fefd7af5d5e98d381558af5a291f7a Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Thu, 13 Oct 2016 11:26:10 +0200 Subject: [PATCH 6/6] Improve log message Instead of always reporting that it waits 30s, it reports the actual time it waits. Contributes to issue CURA-2630. --- NetworkPrinterOutputDevice.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NetworkPrinterOutputDevice.py b/NetworkPrinterOutputDevice.py index ac3af93c84..619a70a952 100644 --- a/NetworkPrinterOutputDevice.py +++ b/NetworkPrinterOutputDevice.py @@ -320,7 +320,7 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): while time_since_last_response - self._recreate_network_manager_time * self._recreate_network_manager_count > self._recreate_network_manager_time and counter < 10: counter += 1 self._recreate_network_manager_count += 1 - Logger.log("d", "Timeout lasted over 30 seconds (%.1fs), re-checking connection.", time_since_last_response) + Logger.log("d", "Timeout lasted over %.0f seconds (%.1fs), re-checking connection.", self._recreate_network_manager_time, time_since_last_response) self._createNetworkManager() return @@ -495,7 +495,7 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): print_information = Application.getInstance().getPrintInformation() - # Check if PrintCores / materials are loaded at all. Any failure in these results in an Error. + # Check if print cores / materials are loaded at all. Any failure in these results in an error. for index in range(0, self._num_extruders): if print_information.materialLengths[index] != 0: if self._json_printer_state["heads"][0]["extruders"][index]["hotend"]["id"] == "":