脚本在读取stdout时卡住,不再继续执行,也不发生终止
import subprocess
p = subprocess.Popen(["mplayer", "-slave", "-quiet", "/home/pi/Music/爱的翅膀.mp3"], stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE, shell = False)
p.stdin.write('\n')
print p.stdout.read() //此处
p.stdin.write('get_time_pos\n')
print p.stdout.read()
mplayer播放时会向stout输入大量字符,超过了4096造成死锁,输出信息不在我的需求之中,因此决定修改
stdout=open("/dev/null","w")
,解决问题。参考博客http://blog.csdn.net/imzoer/a...