From e89f8a805bc47f8d951fcbfb350a3b40d8befbd3 Mon Sep 17 00:00:00 2001 From: Hemna Date: Sat, 24 Feb 2024 14:26:55 -0500 Subject: [PATCH] Added some missing classes to threads Added new APRSDupeThread --- aprsd/threads/__init__.py | 2 +- aprsd/threads/rx.py | 14 +++++++++++--- aprsd/threads/tx.py | 2 ++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/aprsd/threads/__init__.py b/aprsd/threads/__init__.py index bf8cb23..9220a65 100644 --- a/aprsd/threads/__init__.py +++ b/aprsd/threads/__init__.py @@ -4,7 +4,7 @@ import queue # aprsd.threads from .aprsd import APRSDThread, APRSDThreadList # noqa: F401 from .keep_alive import KeepAliveThread # noqa: F401 -from .rx import APRSDRXThread # noqa: F401 +from .rx import APRSDRXThread, APRSDDupeRXThread, APRSDProcessPacketThread # noqa: F401 packet_queue = queue.Queue(maxsize=20) diff --git a/aprsd/threads/rx.py b/aprsd/threads/rx.py index 98e5054..7c8e422 100644 --- a/aprsd/threads/rx.py +++ b/aprsd/threads/rx.py @@ -58,12 +58,13 @@ class APRSDRXThread(APRSDThread): pass -class APRSDPluginRXThread(APRSDRXThread): +class APRSDDupeRXThread(APRSDRXThread): """Process received packets. This is the main APRSD Server command thread that - receives packets from APRIS and then sends them for - processing in the PluginProcessPacketThread. + receives packets and makes sure the packet + hasn't been seen previously before sending it on + to be processed. """ def process_packet(self, *args, **kwargs): @@ -118,6 +119,13 @@ class APRSDPluginRXThread(APRSDRXThread): self.packet_queue.put(packet) +class APRSDPluginRXThread(APRSDDupeRXThread): + """"Process received packets. + + For backwards compatibility, we keep the APRSDPluginRXThread. + """ + + class APRSDProcessPacketThread(APRSDThread): """Base class for processing received packets. diff --git a/aprsd/threads/tx.py b/aprsd/threads/tx.py index 708d263..84dd7dd 100644 --- a/aprsd/threads/tx.py +++ b/aprsd/threads/tx.py @@ -37,6 +37,8 @@ msg_throttle_decorator = decorator.ThrottleDecorator(throttle=msg_t) ack_throttle_decorator = decorator.ThrottleDecorator(throttle=ack_t) + +@msg_throttle_decorator.sleep_and_retry def send(packet: core.Packet, direct=False, aprs_client=None): """Send a packet either in a thread or directly to the client.""" # prepare the packet for sending.