def f(x):
    print('PID: %d' % os.getpid())
time.sleep(x)
complex_obj = 5
return complex_obj
if __name__ == '__main__':
    multiprocessing.set_start_method('spawn')
pool = multiprocessing.Pool(4, maxtasksperchild=1)
pool.map(f, [5] * 30, chunksize=1)
pool.close()
multiprocessing.Pool с maxtasksperchild создает одинаковые PID