Concurrent in Python 2

2019-07-24 06:59发布

问题:

I have a function pre_raw() and pandas data train_raw.values in python3 I could like this:

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

How to wrote it on Python2?

Thanks.

回答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()