Multiprocessing Queue in Python

后端 未结 5 899
抹茶落季
抹茶落季 2020-12-07 23:48

I\'m trying to use a queue with the multiprocessing library in Python. After executing the code below (the print statements work), but the processes do not quit after I call

5条回答
  •  佛祖请我去吃肉
    2020-12-08 00:26

    You have to clear the queue before joining the process, but q.empty() is unreliable.

    The best way to clear the queue is to count the number of successful gets or loop until you receive a sentinel value, just like a socket with a reliable network.

提交回复
热议问题