Python how to kill threads blocked on queue with signals?

前端 未结 6 1050
既然无缘
既然无缘 2020-12-18 03:30

I start a bunch of threads working on a queue and I want to kill them when sending the SIGINT (Ctrl+C). What is the best way to handle this?

targets = Queue.         


        
6条回答
  •  粉色の甜心
    2020-12-18 04:13

    Why don't you set timeouts for any operation on the queue? Then your threads can regular check if they have to finish by checking if an Event is raised.

提交回复
热议问题