在Jenkins上运行脚本中的并行命令

6gpjuf90  于 2022-09-20  发布在  Jenkins
关注(0)|答案(0)|浏览(104)

我有一个python脚本,在其中我使用子进程运行两个命令。我希望这些命令并行运行。当我在我的机器上运行python脚本时,这些命令是并行运行的,但是当我通过Jenkins运行脚本时,它会一个接一个地运行它们。我如何在Jenkins中并行运行这些命令?

reg_path = os.environ['PWD']
    command1 = f'python3 {python_script_path} {reg_path} '
    command2 = f'python3 {python_script_path} {reg_path} '

    processes = []

    for i in range(1):
        f = subprocess.Popen(command2, shell=True,stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        p = subprocess.Popen(command1, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        processes.append((p, f))
        p.wait()
        out, err = p.communicate()
        fout, ferr = f.communicate()
        p.kill()
        f.kill()

        errMsg = 'other processes are running'
        assert errMsg in str(fout) or errMsg in str(out)

谢谢

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题