我用
Popen
来执行一个字符串cmd
。 cmd
使用 ascp 发送文件。想用readline()
读取发送进度的百分比,但是每次都会卡在readline
中
import subprocess
cmd = "ascp xxxxxxxxx xxxxxxx"
ps = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderror=subprocess.PIPE)
while ps.poll() is None():
line = ps.stdout.readline() # I can not get output during transfer, it will stuck here
print(line)
ps.wait()