blocking file.readlines() needed

Peter Otten __peter__ at
Fri Aug 13 19:55:19 CEST 2004

Uwe Mayer wrote:

> I am looking for a way to make the call to a file objects readline()
> method blocking when there is no more data, until data is appended to the
> file, similar to the way
> $ tail -F <system log file>
> works.
> However, file.readlines() aborts and returns an empty list.
> Any ideas?

The naive way to do it:

while True:
    while True:
        line = f.readline()
        if not line:
        print line,


More information about the Python-list mailing list