bob gailer wrote:


You call sleep only when the file is updated. As long as the file is not updated the loop runs continuously and therefore 100%.

and is there any way to fix it?

move the sleep call out of the if, and put the update of old_time in the if

   while True:
       new_time = os.stat(fname).st_mtime
       if new_time > old_time:
           updated = return_tail(fname, bufsize, linesep)
           for i in updated:
               print i
           old_time = new_time
       time.sleep(sec_to_wait)

Thank You Bob

--
Powered by Gentoo GNU/Linux
http://linuxcrazy.com
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to