我在寻找使用select.select()与subprocess监控stdout的示例
基本上,我有一个应用程序,它是通过
p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
加载的。我可以用 p.stdin.write() 发送命令,没什么问题,但我需要监控标准输出(stdout)来获取服务器的响应。整个过程是在一个 TCP 服务器里面运行的,所以我想知道当调用 select.select() 时,它是否会停止执行。我也找不到任何使用 select.select 的示例代码,手册页面看起来有点让人困惑。这里有人能给我一些建议吗?
1 个回答
0
如果你给 timeout
参数设置了一个非空的值,这样就能确保 select()
不会一直等待。