[英]python Problems with using multiple processes to process files
上一個問題解決了: Python中如何控制調用外部命令的子進程數?
新問題是我如何批量 luanch cmd?示例代碼可以正常運行,但只有最后一個文件執行enter image description here
def run(v):
for i in os.listdir(output_lineEdit): #use "for" list all files
if i.split(".")[1] == "ma": # use "if" choose ".ma" files
mapath = i
cmd = '"{mayaBatchPath}" -batch -file "{maPath}" -script "{melFile}" "{plugins}"'.format(
mayaBatchPath=MAYABATCHPATH,# mayabatch.exe path
melFile=melFile, #.mel files
maPath=output_lineEdit+"\\"+mapath, # maya source files
plugins="-noAutoloadPlugins",
)
subprocess.run(cmd, shell=True)
def main():
with Pool(2) as pool:
pool.map(run, range(10))
if __name__ == '__main__':
main()
您忘記在循環中包含subprocess.run(cmd, shell=True)
。 因此cmd
字段僅寫入最后一次迭代並使用它
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.