tail multiple logfiles in python
<p>This is probably a bit of a silly excercise for me, but it raises a bunch of interesting questions. I have a directory of logfiles from my chat client, and I want to be notified using notify-osd every time one of them changes. </p>

<p>The script that I wrote basically uses os.popen to run the linux tail command on every one of the files to get the last line, and then check each line against a dictionary of what the lines were the last time it ran. If the line changed, it used pynotify to send me a notification. </p>

<p>This script actually worked perfectly, except for the fact that it used a huge amount of cpu (probably because it was running tail about 16 times every time the loop ran, on files that were mounted over sshfs.)</p>

<p>It seems like something like <a href="http://stackoverflow.com/questions/1703640/how-to-implement-a-pythonic-equivalent-of-tail-f">this</a> would be a great solution, but I don't see how to implement that for more than one file. </p>

<p><a href="http://pastie.org/1814035" rel="nofollow">Here</a> is the script that I wrote. Pardon my lack of comments and poor style.</p>

<p>Edit: To clarify, this is all linux on a desktop. </p>
