The bug is caused by multi-threading. Since producer is continuously producing and the status of the task is modified between reading the status and polling the queue. So the task is blocked due to this reason the thread will not exit.
After producer finishing all its job, it can put a signal into the queue and the consumer will check if producer is end and will pass the signal to next consumer.
# Producer
# Put a exit signal into the queue to inform the producer
self.task_queue.put(None)
# Consumer
if task is None:
self.task_queue.put(None)
break
In dehaze_transmission.py, the task queue will block forever.