【发布时间】:2010-03-09 03:01:32
【问题描述】:
我创建了一个先进先出:
mkfifo tofetch
我运行这个 python 代码:
fetchlistfile = file("tofetch", "r")
while 1:
nextfetch = fetchlistfile.readline()
print nextfetch
正如我所希望的,它在 readline 上停滞不前。我跑:
echo "test" > tofetch
我的程序不再停止。它读取该行,然后继续永远循环。没有新数据为什么不会再次停顿?
我也尝试查看“not fetchlistfile.closed”,我不介意在每次写入后重新打开它,但 Python 认为 fifo 仍然打开。
【问题讨论】: