def tail(f):
    f.seek(0, 2)
while True:
    line = f.readline()
if not line:
    time.sleep(0.1)
continue
yield line

def process_matches(matchtext):
    while True:
        line = yield
if matchtext in line:
    do_something_useful()
list_of_matches = ['ERROR', 'CRITICAL']
matches = [process_matches(string_match) for string_match in list_of_matches]
for m in matches:
    next(m)
while True:
    auditlog = tail(open(log_file_to_monitor))
for line in auditlog:
    for m in matches:
        m.send(line)
How to implement a pythonic equivalent of tail -F?