real time subprocess.Popen via stdout and PIPE

前端 未结 8 1440

I am trying to grab stdout from a subprocess.Popen call and although I am achieving this easily by doing:

cmd = subprocess.Popen(\'         


        
8条回答
  •  自闭症患者
    2020-11-30 05:37

    To get output "in real time", subprocess is unsuitable because it can't defeat the other process's buffering strategies. That's the reason I always recommend, whenever such "real time" output grabbing is desired (quite a frequent question on stack overflow!), to use instead pexpect (everywhere but Windows -- on Windows, wexpect).

提交回复
热议问题