From e9e7e6cd3b3ae395313166b76859db3070c5eed5 Mon Sep 17 00:00:00 2001 From: Florian Vahl <7vahl@informatik.uni-hamburg.de> Date: Wed, 17 Jan 2024 12:16:31 +0100 Subject: [PATCH] FIx assertion print and socket creation --- game_controller_hl/game_controller_hl/receiver.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/game_controller_hl/game_controller_hl/receiver.py b/game_controller_hl/game_controller_hl/receiver.py index f1fcae7..b5ce20e 100755 --- a/game_controller_hl/game_controller_hl/receiver.py +++ b/game_controller_hl/game_controller_hl/receiver.py @@ -84,10 +84,11 @@ def __init__(self, *args, **kwargs): def _open_socket(self) -> socket.socket: """ Creates the socket """ - self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) - self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - self.socket.bind(self.addr) - self.socket.settimeout(2) + new_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) + new_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + new_socket.bind(self.addr) + new_socket.settimeout(2) + return new_socket def receive_forever(self): """ Waits in a loop for new packages """ @@ -119,7 +120,7 @@ def receive_and_answer_once(self): self.answer_to_gamecontroller(peer) except AssertionError as ae: - self.get_logger().error(ae) + self.get_logger().error(str(ae)) except socket.timeout: self.get_logger().info("No GameController message received (socket timeout)", throttle_duration_sec=5) except ConstError: