From f29f7b20e395c99903f87b9118c646f29cf327e9 Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Fri, 22 Jan 2021 17:34:35 +0100 Subject: [PATCH] change shutdown handling to be able to join() --- owrx/audio.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/owrx/audio.py b/owrx/audio.py index fd57262..7ac3733 100644 --- a/owrx/audio.py +++ b/owrx/audio.py @@ -46,8 +46,6 @@ class QueueWorker(threading.Thread): job = self.queue.get() if job is PoisonPill: self.doRun = False - # put the poison pill back on the queue for the next worker - self.queue.put(PoisonPill) else: try: job.run() @@ -102,10 +100,14 @@ class DecoderQueue(Queue): while not self.empty(): job = self.get() job.unlink() + self.task_done() except Empty: pass - # put() PoisonPill to tell workers to shut down - self.put(PoisonPill) + # put() a PoisonPill for all active workers to shut them down + for w in self.workers: + if w.is_alive(): + self.put(PoisonPill) + self.join() def put(self, item, **kwars): self.inCounter.inc()