我的代码如下。调用concurrent.futures并行作业的麻烦
executor = concurrent.futures.ThreadPoolExecutor(max_workers=4)
for cj in self.parent_job.child_jobs:
executor.map(cj.runCommand())
高清runCommand(个体经营): 使用os.system(self.cmd_line) verifyOutputFiles() ...
runCommand需求并行所有child_jobs执行。一次只能将一个child_job传递给runCommand。
但runCommand一次只能调用一次。但是我需要在同一时间为所有儿童工作调用它。任何有助于实现这一目标,在executor.map
API认识
child_jobs有要执行的命令列表。我需要并行运行它们。 – Hema 2013-03-21 13:47:25
cj只有一个子作业,self.parent_job.child_jobs有所有子作业的列表。如果我们像executor.map(cj.runCommand,self.parent_job.child_jobs)一样执行,哪一个会到达runCommand – Hema 2013-03-21 13:56:42
我不确定@AndrewDalke建议的是什么。我认为'cj.runCommand'绑定到'cj'实例,所以对我来说没有意义。我认为我发布的内容应该有效 - @ user2194611你试过了吗? – kkonrad 2013-03-21 21:51:47