所以我有以下代码可以正常工作:
from concurrent.futures import ProcessPoolExecutor
import itertools
def grid_search_helper(vec_input):
v1 = vec_input[0]
v2 = vec_input[1]
v3 = vec_input[2]
d = {'v1' : v1, 'v2' : v2, 'v3' : v3}
return(d)
idx = range(0,10)
cutoff = np.ndarray.tolist(np.arange(0.6,0.95,0.05))
opt = [2]
iters = itertools.product(idx, cutoff, opt)
with ProcessPoolExecutor(max_workers = 11) as executor:
for res in executor.map(grid_search_helper,iters):
print(res)
然后我尝试 zip() 打印 ProcessPoolExecuter 正在处理的迭代,但是当我运行以下代码时没有打印任何内容:
from concurrent.futures import ProcessPoolExecutor
import itertools
def grid_search_helper(vec_input):
v1 = vec_input[0]
v2 = vec_input[1]
v3 = vec_input[2]
d = {'v1' : v1, 'v2' : v2, 'v3' : v3}
return(d)
idx = range(0,10)
cutoff = np.ndarray.tolist(np.arange(0.6,0.95,0.05))
opt = [2]
iters = itertools.product(idx, cutoff, opt)
with ProcessPoolExecutor(max_workers = 11) as executor:
for res, itr in zip(executor.map(grid_search_helper,iters), iters):
print(res, itr)
我不知道为什么。有人可以帮忙吗?