Python子进程导致shell的延迟

时间:2014-05-13 02:39:36

标签: python shell subprocess latency

以下代码完全正常。但是,一旦调用了子进程并执行了外部python脚本,它就会开始快速弹出一个命令提示符,因为脚本的输出是纯文本。但是,我们已经尝试了一切来禁用弹出窗口。我们尝试添加'shell = False'和'shell = None'。我们甚至尝试编辑外部脚本本身并修改其子进程调用,但它没有。

if os.path.exists(oldpath): shutil.copy(root.wgetdir + "\\" + root.website.get() + "\\" + item, keyworddir + "\\" + item)
            shellreturn = subprocess.check_output(["C:\Python34\python",root.wgetdir + "\html2text.py", keyworddir + "\\" + item])
            print(shellreturn)
            shelllist = shellreturn.decode().splitlines()

1 个答案:

答案 0 :(得分:0)

感谢@ J.F的相关帖子。塞巴斯蒂安,我能够弄清楚如何消除shell弹出窗口。以下是我使用的代码。

startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW      
shellreturn = subprocess.check_output(["C:\Python34\python", root.wgetdir + "\html2text.py", keyworddir + "\\" + item], startupinfo=startupinfo) #this could be any subprocess.