I'm writing a component of a web app that displays the tail of a log file.
My current attempt is to use web sockets to emit the changes in the file, ensure that I have fewer than n lines, and tack it into a text area.
My current problem is how to generate 'on change' events for the log file in Python.
I could conceivably detect changes of some_log.log by creating a copy some_copy.log with shutil, detect the last time the file was changed with os.path.getmtime, take the diff and emit the changes. This reeks of inefficiency.
Does anyone have suggestions for asynchronously detecting changes in files using Python? I'm using Python 2.7.6.