The previous problem was solved: How do I control the number of child processes used to call external commands in Python?
the new question is how can i batch luanch cmd?the sample code can normal operation,But only the last file executes 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()