I am trying to create a pool inside a pool to parallelize a for cycle. I'm trying to do this to see if it is faster than running a for cycle with only one pool creation. My issue is that the code I wrote doesn't seem to ever finish running and I don't quite get why. Here is the code:
import numpy as np
import multiprocessing as mp
import time
cpus = mp.cpu_count() - 1
def f(x):
lista = list(pool.map(time.sleep, [1,2,3] * x))
print('done')
return lista
pool = mp.Pool(cpus)
lista2 = pool.map(f, range(2))
pool.close()
pool.join()