Possible Duplicate:
tail -f in python with no time.sleep
I am trying to monitor a log file that is being written to (like tail -f), and I can't figure out how to make readline() block once it reaches eof. All of my googling has only turned up solutions to make things NON-blocking. Does anyone know a way to make a call like this block, so I DON'T have to poll? (I'm perfectly capable of polling and sleeping already, so if you suggest that I'm going to rate you down.)
fh = open('logfile')
# I only want new output, so seek to the end of the file
fh.seek(-1,2)
while True:
# I want this to block until the file has new output,
# but it sees eof and returns '' immediately
line = fh.readline()
# ... process the line