mirror of
https://github.com/craigerl/aprsd.git
synced 2024-12-21 09:01:23 -05:00
Fix access to PacketList._maxlen
This commit is contained in:
parent
7c935345e5
commit
1c9f25a3b3
@ -18,12 +18,13 @@ class PacketList(objectstore.ObjectStoreMixin):
|
|||||||
lock = threading.Lock()
|
lock = threading.Lock()
|
||||||
_total_rx: int = 0
|
_total_rx: int = 0
|
||||||
_total_tx: int = 0
|
_total_tx: int = 0
|
||||||
|
_maxlen: int = 100
|
||||||
|
|
||||||
def __new__(cls, *args, **kwargs):
|
def __new__(cls, *args, **kwargs):
|
||||||
if cls._instance is None:
|
if cls._instance is None:
|
||||||
cls._instance = super().__new__(cls)
|
cls._instance = super().__new__(cls)
|
||||||
cls._maxlen = CONF.packet_list_maxlen
|
cls._instance._maxlen = CONF.packet_list_maxlen
|
||||||
cls.data = {
|
cls._instance.data = {
|
||||||
"types": {},
|
"types": {},
|
||||||
"packets": OrderedDict(),
|
"packets": OrderedDict(),
|
||||||
}
|
}
|
||||||
@ -58,7 +59,7 @@ class PacketList(objectstore.ObjectStoreMixin):
|
|||||||
def _add(self, packet):
|
def _add(self, packet):
|
||||||
if packet.key in self.data["packets"]:
|
if packet.key in self.data["packets"]:
|
||||||
self.data["packets"].move_to_end(packet.key)
|
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"].popitem(last=False)
|
||||||
self.data["packets"][packet.key] = packet
|
self.data["packets"][packet.key] = packet
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user