future_list = []
result = {"weight_1":[],"weight_2":[]}
with ProcessPoolExecutor(max_workers=10) as exec:
for weight in weight_lists:
try:
future = exec.submit($func_name,$para)
future_list.append(future)
except Exception as e:
print(e)
for future in as_completed(future_list):
try:
info = future.result()
print(idx,info['weight'],info['exec_time'] )
result['weight_1'].append(info['weight'])
result['weight_2'].append(info['weight'])
except Exception as e:
print(e)
pd.DataFrame(result).to_excel(info_path + "/idx=" + str(idx) + ".xlsx")
python多进程处理(ProcessPoolExecutor)
于 2024-03-12 12:41:12 首次发布