管道损坏:使用多处理池中的地图

时间:2017-12-12 09:58:29

标签: python python-2.7 multiprocessing

我尝试在HPC中使用多处理来加速我的代码。它运行正常,但我添加了一些计算,突然它开始发布此错误。我在没有多处理的情况下运行它并且很好。

第一个~20个函数执行适用于多处理,但之后会开始滚雪球,这个错误会越来越多地出现。

在日志中写入"在某些时候超过步骤内存限制"和"原因:' RuntimeError('调用Python对象时超出了最大递归深度','"

import os
from multiprocessing import Pool

def eigencen(filename):
    --DO complicated stuff here--

for f in os.listdir(FOLDER):
    list_fn.extend([f])

def evaluation(f_list):
    return list(Pool(processes=28).map(eigencen, f_list))
evaluation(list_fn)

我能以某种方式修复它吗?如果没有多处理,它将需要永远运行。

1 个答案:

答案 0 :(得分:1)

尝试使用concurrent.futures模块:

from concurrent import futures

def evaluation(f_list):
    with futures.ProcessPoolExecutor() as pool:
        return pool.map(eigencen, f_list)