wait until change

Werner Schiendl n17999950.temp.werner at neverbox.com
Fri Oct 17 15:36:35 EDT 2003


Hi,

What's the problem?

Just wait as long as you can accept to be "late" when your file changes.

So if you can accept e. g. 5 seconds delay, you'll change Lane's example to:

time=os.stat(file)[8]

# analyze data

while 1:
	if os.stat(file)[8]>time:
		#analyze data again
	else:
		time.sleep(5)


This will drastically reduce your CPU load ;-)

hth

Werner



Tom wrote:
> Peter Hansen wrote:
> 
>> Use time.sleep().
>>
>> -Peter
>>
> If I use sleep, I have to know how long the process should sleep, but 
> sometimes it should sleep for seconds and sometimes for minutes. So it 
> would be good if I can put it to sleep and somehow wake it up if the 
> file changed.
> 
> Tom
> 





More information about the Python-list mailing list