From 1c9f25a3b3043352909504e62fe70f13ea439107 Mon Sep 17 00:00:00 2001 From: Hemna Date: Mon, 15 Apr 2024 09:19:05 -0400 Subject: [PATCH] Fix access to PacketList._maxlen --- aprsd/packets/packet_list.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/aprsd/packets/packet_list.py b/aprsd/packets/packet_list.py index 54a2595..92fe8d7 100644 --- a/aprsd/packets/packet_list.py +++ b/aprsd/packets/packet_list.py @@ -18,12 +18,13 @@ class PacketList(objectstore.ObjectStoreMixin): lock = threading.Lock() _total_rx: int = 0 _total_tx: int = 0 + _maxlen: int = 100 def __new__(cls, *args, **kwargs): if cls._instance is None: cls._instance = super().__new__(cls) - cls._maxlen = CONF.packet_list_maxlen - cls.data = { + cls._instance._maxlen = CONF.packet_list_maxlen + cls._instance.data = { "types": {}, "packets": OrderedDict(), } @@ -58,7 +59,7 @@ class PacketList(objectstore.ObjectStoreMixin): def _add(self, packet): if packet.key in self.data["packets"]: self.data["packets"].move_to_end(packet.key) - elif len(self.data["packets"]) == self.maxlen: + elif len(self.data["packets"]) == self._maxlen: self.data["packets"].popitem(last=False) self.data["packets"][packet.key] = packet