python parallel map (multiprocessing.Pool.map) with global data

后端 未结 2 1566
没有蜡笔的小新
没有蜡笔的小新 2021-02-02 00:27

I\'m trying to call a function on multiple processes. The obvious solution is python\'s multiprocessing module. The problem is that the function has side effects.

2条回答
  •  别跟我提以往
    2021-02-02 01:01

    Have func return a tuple with the results you want from the processing and the thing you want to append to glob_data. Then, when the p.map has completed, you can extract the results from the first elements in the returned tuples and you can build glob_data from the second elements.

提交回复
热议问题