0

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()
xh c
  • 15
  • 3

1 Answers1

0

You forgot to include subprocess.run(cmd, shell=True) in the loop. Thus cmd field only the last iteration is written and you use it

Devid Mercer
  • 160
  • 1
  • 2
  • 8