3
我创建了一个非常简单的Python脚本:理解“在蟒蛇的tail -f”
def read_then_follow(file):
for line in file:
yield line
while True:
line = file.readline()
if not line:
time.sleep(1.0)
continue
yield line
for line in read_then_follow("some_file.txt"): print line
文件“some_file.txt”包含文本的几行,这将被写入到屏幕时,我运行脚本。如果我然后在echo "line" >> some_file.txt
的文件中添加一行,该行将在1秒内打印到屏幕上。但是:如果我打开文件vim,在底部添加一行并保存,脚本停止运行。它既不会写入vim中写入的新行,也不会响应进一步的echo ...
命令。
为了您的信息,我目前在Ubuntu 10.10上使用python 2.6.6。
啊,这似乎是一个非常合理的解释。谢谢! – 2011-03-16 14:17:37
您可以在Vim中查看[:help crontab](http://vimdoc.sourceforge.net/htmldoc/options.html#crontab)了解有关该主题的一些信息。这是同样的问题。 – Carpetsmoker 2011-03-16 14:18:42