just wanted to know a way to save the objects that come out of the functions that I pool in a multi-process environment (python 3.5).
Code to pool (a simple example):
import numpy as np
vct_list = [0, 1]
def f_to_pool(vector_list):
chosen_nmb = np.random.choice(vector_list)
status_ = True if chosen_nmb == 0 else False
return chosen_nmb * 4, status_
scenarios = range(100)
numbers_processed = []
all_status = []
for _ in scenarios:
nmb_processed, status = f_to_pool(vct_list)
numbers_processed.append(nmb_processed)
all_status.append(status)
whereas the multi-processing framework is multiprocessing.Pool:
pool = multiprocessing.Pool(nmb_of_proc)
results = pool.map(function, objects)
pool.close()
the issue is that, even if I could run the in async and collect the results as shown in the docs ( https://docs.python.org/3.5/library/multiprocessing.html#using-a-pool-of-workers), the process would remain the same and, since I am using this technique to expand my computational power (this is NOT an I/O problem), that would be of no use to me.
Any suggestions?