我试图为每个 cpu 提供一个作业来创建一些来自不同批次的 json 文件并优化流程,但是当提交作业时没有做任何事情它返回函数的打印语句而不是 createjson_multi 中的第一个打印语句
我正在提交这样的工作:
def multiprocess(configfile, engine, local_dest):
num_cpus = os.cpu_count()
batch_groups = [(i,) for i in range(1, 3)]
print(batch_groups)
with ProcessPoolExecutor(max_workers=3) as executor:
for batch_group in batch_groups:
print(batch_group[0])
executor.submit(createjson_multi, configfile, engine, local_dest, batch_group)
time.sleep(5)
print('up to here works')
但不调用调用此函数,因为不打印任何内容:
def createjson_multi(configfile, engine, local_dest, batch_group):
print(f'process working for: {batch_group}')
#process to generate the json from here...