Check File Change Every 10 Seconds

Tommy Nordgren tommy.nordgren at
Tue Oct 23 00:21:49 CEST 2007

On 22 okt 2007, at 16.45, Robert Rawlins - Think Blue wrote:

> Thanks for your time Gabriel,
> That certainly looks to be the type of thing that I'm looking to  
> achieve, however, I forgot to mention I'm running this on a Linux  
> platform and not a Win32 one :-( Sorry.
> I'm sure similar things are achievable, I've used os.stat before  
> now to get the time stamp for when a file was last changed, if I  
> perhaps combine this with the while 1: inside a thread I can  
> achieve the same end result? Sound like a good idea?
> I just wasn’t sure how safe it was to spawn a thread like this  
> which contains an infinite loop.
> Thanks again for your time,
> Rob

	Don't use os.stat Use os.fstat instead on the open filedescriptor  
associated with your file.
If you use stat on a portable, and poll too often, your hard drive  
will never go to sleep when idle.
	fstat works on the cached, in memory, directory info of the file.
When it's changed, rewind the file and reparse.

> ------
What is a woman that you forsake her, and the hearth fire and the  
home acre,
to go with the old grey Widow Maker.  --Kipling, harp song of the  
Dane women
Tommy Nordgren
tommy.nordgren at

More information about the Python-list mailing list