the following code
import multiprocessing as mpfrom multiprocessing.managers import SyncManagern_cores = mp.cpu_count()def parallel_fn(job_n, cache): cache['job_b'] = job_n return job_nif __name__=="__main__": with SyncManager() as manager: shared_cache = manager.dict() args = list(zip(range(n_cores), shared_cache)) with mp.Pool(n_cores) as pool: result = pool.starmap(parallel_fn, args) print(result) print(shared_cache)
returns
16Shared dict before: {}Pool return: []Shared dict after: {}
I was expecting 16 values in return from the pool and 16 values in the shared dictionary, but both are empty, anyone can help me out?