Python 3.x:多处理池未按预期加快执行速度

时间:2018-12-24 12:09:39

标签: python-3.x python-multiprocessing

多处理池未按预期加快执行速度。

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

注意:添加了多处理池代码快照,而不是整个实现。

0 个答案:

没有答案