Python 2中的并发

时间:2016-04-14 10:42:05

标签: concurrency multiprocessing

我在python3中有一个函数pre_raw()和pandas data train_raw.values我可以这样:

with concurrent.futures.ThreadPoolExecutor() as executor:
     executor.map(pre_raw, train_raw.values)

如何在Python2上编写它?

感谢。

1 个答案:

答案 0 :(得分:1)

procs=[]
for val in train_raw.values:
    p = multiprocessing.Process(target=pre_raw, args=(val,))
    procs.append(p)
    p.start()

for p in procs:
    p.join()