From 0518ff93582bd16af6770c13fdd9913d538939b9 Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Wed, 5 Aug 2020 20:04:41 +0200 Subject: [PATCH] provide information to the queue which entries are done --- owrx/connection.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/owrx/connection.py b/owrx/connection.py index 5673703..dd8cc27 100644 --- a/owrx/connection.py +++ b/owrx/connection.py @@ -26,21 +26,23 @@ logger = logging.getLogger(__name__) class Client(ABC): def __init__(self, conn): self.conn = conn - self.multithreadingPipe = Queue(100) + self.multithreadingQueue = Queue(100) def mp_passthru(): run = True while run: try: - data = self.multithreadingPipe.get() + data = self.multithreadingQueue.get() self.send(data) except (EOFError, OSError, ValueError): run = False except Exception: logger.exception("Exception on client multithreading queue") + finally: + self.multithreadingQueue.task_done() # unset the queue object to free shared memory file descriptors - self.multithreadingPipe = None + self.multithreadingQueue = None threading.Thread(target=mp_passthru).start() @@ -54,10 +56,10 @@ class Client(ABC): self.conn.close() def mp_send(self, data): - if self.multithreadingPipe is None: + if self.multithreadingQueue is None: return try: - self.multithreadingPipe.put(data, block=False) + self.multithreadingQueue.put(data, block=False) except Full: self.close()