多处理池未按预期加快执行速度。
from multiprocessing import Pool, cpu_count
def process_data(row,is_heatmap=False,watchlist=False):
#data processing to get data in needed format
#return formatted data
def filter_automation_data():
#initialised data#
mp=Pool(min(8,max(cpu_count(),4)))
for row in database.get_view_result(design_doc, view):
row_data.append(mp.apply_async(process_data,(row, is_heatmap, watchlist,)))
mp.close()
mp.join()
returned_data = [result.get() for result in row_data]
return returned_data
注意:添加了多处理池代码快照,而不是整个实现。