I want to append list Python parallel processing. I write code as follow:
from joblib import Parallel
from multiprocessing.managers import BaseManager
manager = multiprocessing.Manager()
inputs = enumerate(my_list)
lproxy = manager.list()
d = lproxy
d.append([]) #init empty list
num_cores = multiprocessing.cpu_count()
_ = Parallel(n_jobs=num_cores)(d[0].append(word) for idx, word in inputs)
Then my parallel job return 'NoneType' object is not iterable. How to append to list in above case? In second example I test Parallel as follow:
from joblib import Parallel, delayed
def process(word) :
print(word)
results = Parallel(n_jobs=num_cores)(delayed(process(word)) for idx, word in inputs)
and this return 'function' object is not iterable. Is this function have to be written somehow specially?
What's a god practice of parallel appending to the list?