Subprocess.Popen仅第二次运行

时间:2018-04-05 15:08:35

标签: python windows subprocess popen

我有一个启动控制器,它运行我试图部署的每个工具的每个文件夹中包含的boot.py文件。我希望我的启动控制器同时运行所有这些启动文件。配置文件包含工具名称和所需版本,这有助于生成boot.py的路径。

def run_boot():
    config_file = get_config_file()
    parse_config_file.init(config_file)
    tools = parse_config_file.get_tools_to_deploy()
    #tools is now a list of tool names
    top_dir = os.getcwd()
    for tool in tools:
        ver = parse_config_file.get_tool_version(tool).strip()
        boot_file_path = "{0}\\Deploy\\{1}\\{2}".format(os.getcwd(),tool,ver)
        try:
            subprocess.Popen('boot.py', shell=True,  cwd=boot_file_path)
        except:
            print ("{0} failed to open".format(tool))
        print(tool, boot_file_path)
        os.chdir(top_dir)

第一次运行时,print(tool, boot_file_path)会执行,但进程不会执行。第二次运行时,进程就会打开。我找不到合理的理由。

0 个答案:

没有答案
相关问题