tail.py: Add a function to run periodically while waiting for the next line.