1
0
mirror of https://github.com/craigerl/aprsd.git synced 2025-09-02 13:17:54 -04:00

Added pause_all, unpause_all in threadlist

This patch adds methods for pausing and unpausing all threads in
the APRSDThreadList.
This commit is contained in:
Hemna 2024-11-23 09:13:35 -05:00
parent 505565d3a6
commit 76d275db9c

View File

@ -40,6 +40,7 @@ class APRSDThread(threading.Thread, metaclass=abc.ABCMeta):
self._pause = False self._pause = False
def stop(self): def stop(self):
LOG.debug(f"Stopping thread '{self.name}'")
self.thread_stop = True self.thread_stop = True
@abc.abstractmethod @abc.abstractmethod
@ -119,6 +120,24 @@ class APRSDThreadList:
LOG.info(F"{th.name} packet {th.packet}") LOG.info(F"{th.name} packet {th.packet}")
th.stop() th.stop()
@wrapt.synchronized
def pause_all(self):
"""Iterate over all threads and pause them."""
for th in self.threads_list:
LOG.info(f"Pausing Thread {th.name}")
if hasattr(th, "packet"):
LOG.info(F"{th.name} packet {th.packet}")
th.pause()
@wrapt.synchronized
def unpause_all(self):
"""Iterate over all threads and resume them."""
for th in self.threads_list:
LOG.info(f"Resuming Thread {th.name}")
if hasattr(th, "packet"):
LOG.info(F"{th.name} packet {th.packet}")
th.unpause()
@wrapt.synchronized(lock) @wrapt.synchronized(lock)
def info(self): def info(self):
"""Go through all the threads and collect info about each.""" """Go through all the threads and collect info about each."""