[Tutor] Reset while loop
David
david at abbottdavid.com
Thu May 7 02:44:55 CEST 2009
When running the program cpu usage is 100%. Here is the part that is
running;
def tail_it(fname, bufsize, linesep):
"""Update if monitored file time changes"""
old_time = os.stat(fname).st_mtime
while True:
new_time = os.stat(fname).st_mtime
if new_time > old_time:
time.sleep(sec_to_wait)
updated = return_tail(fname, bufsize, linesep)
for i in updated:
print i
old_time = new_time
It is waiting here;
new_time = os.stat(fname).st_mtime
Why would something like that happen and is there any way to fix it? The
program is just for me to learn Python, if I wanted to tail a log file I
would just use tail, but an understanding may help in the future.
thanks,
-david
--
Powered by Gentoo GNU/Linux
http://linuxcrazy.com
More information about the Tutor
mailing list