On 6/22/07, Evan Klitzke <[EMAIL PROTECTED]> wrote:
> Everyone,
>
> I'm interested in writing a python program that reads from a log file
> and then executes actions based on the lines. I effectively want to
> write a loop that does something like this:
>
> while True:
>     log_line = log_file.readline()
>     do_something(log_line)
>
> Where the readline() method blocks until a new line appears in the
> file, unlike the standard readline() method which returns an empty
> string on EOF. Does anyone have any suggestions on how to do this?
> Thanks in advance!

I checked the source code for tail and they actually poll the file by
using fstat and sleep to check for changes in the file size. This
didn't seem right so I thought about it more and realized I ought to
be using inotify. So I guess I answered my own question.

-- 
Evan Klitzke <[EMAIL PROTECTED]>
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to