Terminate a Python multiprocessing program once a one of its workers meets a certain condition

后端 未结 4 1594
一向
一向 2020-12-05 03:32

I am writing a Python program using its multiprocessing module. The program calls a number of worker functions, each yielding a random number. I need to terminate th

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-05 04:00

    There is a much cleaner and pythonic way to do what you want to do and it's achieved by using the callback functions offered by multiprocessing.Pool.

    You can check this question to see an implementation example.

提交回复
热议问题