from joblib import Parallel, delayed
def func(v):
temp.append(v)
return
temp = []
Parallel(n_jobs=4)(delayed(func)(v) for v in range(10))
print temp
I want to make shared memory variable. But the value of temp is empty []. How can I do it?
For other method, I tried pickle.dump and load. But there is a lock problem. Please give me advice!
delayed
collects the output returned byfunc
in a list and returns it on completion.You need to use
multiprocessing.Manager.list
, for example:temp[:]
: