detecting document changes

Tim Golden tim.golden at
Wed Aug 27 16:32:44 CEST 2003

From: Alessandro Crugnola *sephiroth* [mailto:alessandro at]
>> Tim Golden:
>> and this one with Win32:

> thanks but that one check only new/deleted/renamed files

Indeed, but as I noted in the original response,
you only need to add a flag or two to the
API call to get modification notifications as
well. (He says, without checking it out for

> ..but is not too stressing for the cpu 
> to check for file changes in a (forever) while loop?

In short, no. Somewhere in the depths of the operating
system is a signal / wait mechanism which sits there
quite quietly until something happens. Anything on Windows
which uses the WaitForSingleObject family of API calls is 
fairly safe. Obviously, there is an overhead (try running 
it against a big directory of constantly-changing files) 
but by and large it's fine.

There is another, deeper, API call which Mark Hammond
introduced into the later versions of win32all. I can't
remember the name of the function, but if you Google
back through looking for FindFirstChangeNotification
and/or my name, you might come across an earlier discussion
on the matter. I haven't tried it myself.

As a final note, you could -- theoretically -- use WMI to
do this same job: it can see directories as objects and
has a notification system, but I tried it once and soon had
to reboot my machine. Don't Do It!


This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:

More information about the Python-list mailing list