From ab2658e48f883fb1c9bb5a311c279cf18f5db487 Mon Sep 17 00:00:00 2001 From: Florian Barthel Date: Tue, 13 Aug 2024 13:16:24 +0200 Subject: [PATCH] increase read try counter --- splatviz_network/splatviz_network.py | 15 +++++++++++++-- viz_renderer/attach_renderer.py | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/splatviz_network/splatviz_network.py b/splatviz_network/splatviz_network.py index fc7396d..fe4b904 100644 --- a/splatviz_network/splatviz_network.py +++ b/splatviz_network/splatviz_network.py @@ -39,8 +39,19 @@ def try_connect(self): def read(self): messageLength = self.conn.recv(4) - messageLength = int.from_bytes(messageLength, 'little') - message = self.conn.recv(messageLength) + expected_bytes = int.from_bytes(messageLength, 'little') + + current_bytes = 0 + try_counter = 10 + counter = 0 + message = bytes() + while current_bytes < expected_bytes: + message += self.conn.recv(expected_bytes - current_bytes) + current_bytes = len(message) + counter += 1 + if counter > try_counter: + print("Package loss") + break return json.loads(message.decode("utf-8")) def send(self, message_bytes, training_stats): diff --git a/viz_renderer/attach_renderer.py b/viz_renderer/attach_renderer.py index cf918c5..ec33918 100644 --- a/viz_renderer/attach_renderer.py +++ b/viz_renderer/attach_renderer.py @@ -58,7 +58,7 @@ def read(self, resolution): try: current_bytes = 0 expected_bytes = resolution * resolution * 3 - try_counter = 3 + try_counter = 10 counter = 0 message = bytes() while current_bytes < expected_bytes: