change shutdown handling to be able to join()
This commit is contained in:
parent
ae1287b8a2
commit
f29f7b20e3
@ -46,8 +46,6 @@ class QueueWorker(threading.Thread):
|
|||||||
job = self.queue.get()
|
job = self.queue.get()
|
||||||
if job is PoisonPill:
|
if job is PoisonPill:
|
||||||
self.doRun = False
|
self.doRun = False
|
||||||
# put the poison pill back on the queue for the next worker
|
|
||||||
self.queue.put(PoisonPill)
|
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
job.run()
|
job.run()
|
||||||
@ -102,10 +100,14 @@ class DecoderQueue(Queue):
|
|||||||
while not self.empty():
|
while not self.empty():
|
||||||
job = self.get()
|
job = self.get()
|
||||||
job.unlink()
|
job.unlink()
|
||||||
|
self.task_done()
|
||||||
except Empty:
|
except Empty:
|
||||||
pass
|
pass
|
||||||
# put() PoisonPill to tell workers to shut down
|
# put() a PoisonPill for all active workers to shut them down
|
||||||
|
for w in self.workers:
|
||||||
|
if w.is_alive():
|
||||||
self.put(PoisonPill)
|
self.put(PoisonPill)
|
||||||
|
self.join()
|
||||||
|
|
||||||
def put(self, item, **kwars):
|
def put(self, item, **kwars):
|
||||||
self.inCounter.inc()
|
self.inCounter.inc()
|
||||||
|
Loading…
Reference in New Issue
Block a user