diff --git a/aprsd/cmds/listen.py b/aprsd/cmds/listen.py index 61ded19..a8066d4 100644 --- a/aprsd/cmds/listen.py +++ b/aprsd/cmds/listen.py @@ -135,7 +135,7 @@ def listen( keepalive.start() LOG.debug("Create APRSDListenThread") - listen_thread = APRSDListenThread(threads.msg_queues, config=config) + listen_thread = APRSDListenThread(threads.packet_queue, config=config) LOG.debug("Start APRSDListenThread") listen_thread.start() LOG.debug("keepalive Join") diff --git a/aprsd/plugins/email.py b/aprsd/plugins/email.py index 557bd19..1e49f4a 100644 --- a/aprsd/plugins/email.py +++ b/aprsd/plugins/email.py @@ -80,7 +80,6 @@ class EmailPlugin(plugin.APRSDRegexCommandPluginBase): def create_threads(self): if self.enabled: return APRSDEmailThread( - msg_queues=threads.msg_queues, config=self.config, ) @@ -502,9 +501,8 @@ def resend_email(config, count, fromcall): class APRSDEmailThread(threads.APRSDThread): - def __init__(self, msg_queues, config): + def __init__(self, config): super().__init__("EmailThread") - self.msg_queues = msg_queues self.config = config self.past = datetime.datetime.now() diff --git a/aprsd/threads/aprsd.py b/aprsd/threads/aprsd.py index 5673fa4..82fb65f 100644 --- a/aprsd/threads/aprsd.py +++ b/aprsd/threads/aprsd.py @@ -1,6 +1,5 @@ import abc import logging -from queue import Queue import threading import wrapt @@ -16,7 +15,6 @@ class APRSDThreadList: threads_list = [] lock = threading.Lock() - global_queue = Queue() def __new__(cls, *args, **kwargs): if cls._instance is None: @@ -26,7 +24,6 @@ class APRSDThreadList: @wrapt.synchronized(lock) def add(self, thread_obj): - thread_obj.set_global_queue(self.global_queue) self.threads_list.append(thread_obj) @wrapt.synchronized(lock) @@ -35,7 +32,6 @@ class APRSDThreadList: @wrapt.synchronized(lock) def stop_all(self): - self.global_queue.put_nowait({"quit": True}) """Iterate over all threads and call stop on them.""" for th in self.threads_list: LOG.info(f"Stopping Thread {th.name}") @@ -50,30 +46,15 @@ class APRSDThreadList: class APRSDThread(threading.Thread, metaclass=abc.ABCMeta): - global_queue = None - def __init__(self, name): super().__init__(name=name) self.thread_stop = False APRSDThreadList().add(self) - def set_global_queue(self, global_queue): - self.global_queue = global_queue - def _should_quit(self): """ see if we have a quit message from the global queue.""" if self.thread_stop: return True - if self.global_queue.empty(): - return False - msg = self.global_queue.get(timeout=1) - if not msg: - return False - if "quit" in msg and msg["quit"] is True: - # put the message back on the queue for others - self.global_queue.put_nowait(msg) - self.thread_stop = True - return True def stop(self): self.thread_stop = True