我正在尝试使用python多处理模块处理大文件。执行下面的代码我得到模块导入错误。 在python2.7控制台上,“来自多处理导入池”工作正常。
from multiprocessing import Pool
import subprocess
def process_line(file):
return "foo"
if __name__ == "__main__":
pool = Pool(4)
with open('file.txt') as source_file:
# chunk the work into batches of 4 lines at a time
results = pool.map(process_line, source_file, 4)
print results