From 6943f43a82752970672f03fc6db5e81f8651e427 Mon Sep 17 00:00:00 2001 From: Jan David Mol <mol@astron.nl> Date: Tue, 15 Jun 2021 04:40:10 +0200 Subject: [PATCH] L2SS-244: Don't go overly complex if we need a new buffer every time anyway. Just return a set of bytes for each packet. --- devices/clients/sst_client.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/devices/clients/sst_client.py b/devices/clients/sst_client.py index a63b04067..cdaba3ad3 100644 --- a/devices/clients/sst_client.py +++ b/devices/clients/sst_client.py @@ -109,11 +109,10 @@ class UDP_Receiver(Thread): This class provides a small wrapper for the OPC ua read/write functions in order to better organise the code """ - def __init__(self, host, port, queue, buffersize=9000, timeout=0.1): + def __init__(self, host, port, queue, timeout=0.1): self.queue = queue self.host = host self.port = port - self.buffersize = buffersize logger.debug("binding a socket on UDP port {} and host {}".format(self.port, self.host)) self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) @@ -132,10 +131,8 @@ class UDP_Receiver(Thread): while self.stream_on: try: - packet = [bytearray(self.buffersize)] - self.sock.recvmsg_into(packet[0:self.buffersize]) + packet, _, _, _ = self.sock.recvmsg() self.queue.put(packet) - except socket.timeout: pass except queue.Full: -- GitLab