In [10]:
#simplest multiprocessing
from multiprocessing import Pool
import multiprocessing as mp

#mp.set_start_method('spawn')

n_processes = max(1,mp.cpu_count()-1)

In [16]:
def f(x):
    return x

with Pool(n_processes) as p:
    print(p.map(f, range(20)))


[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]

In [ ]:


In [ ]:


In [ ]: