Min*_*ngo 15 python subprocess blocking
我正在使用子进程模块调用外部程序(plink.exe)来登录服务器; 但是当我呼叫通信来读取输出时,它就是阻塞.代码如下:
import subprocess
process = subprocess.Popen('plink.exe hello@10.120.139.170 -pw 123456'.split(), shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
print process.communicate() #block here
Run Code Online (Sandbox Code Playgroud)
我知道该块是因为plink.exe它仍在运行; 但我需要在子进程终止之前读取输出.反正有吗?