What is the cleanest way to stop a python multiprocessing worker attached to a queue in an infinite loop?

后端 未结 1 470
孤城傲影
孤城傲影 2021-02-18 17:43

I\'m implementing a producer-consumer pattern in python using multiprocessing.Pool and multiprocessing.Queue. Consumers are pre-forked processes that u

1条回答
  •  粉色の甜心
    2021-02-18 18:43

    I figured out the problem. According to documentation for multiprocessing.Pool.join(), pool needs to be close()ed before it can be join()ed. Adding pool.close() before pool.join() solved the problem.

    0 讨论(0)
提交回复
热议问题