Mark wrote:
> Firstly, It fires potentially hundreds of notifications for a simple 
> save operation. 

That surprised me, although it does depend on what you
call "a simple save operation". But then I saved a trivial
Word doc (assuming you meant something like that) and
I did indeed see nearly 50 combined update/rename/delete/create
operations going on, presumably as Word does things to
avoid corrupting files etc.

> And for a windows copy operation it fires virtually no 
> resaults untill near the end of the copy.  Point being it was very hard 
> for me to determine when actual write operations had finished due to all 
> these sporadic events.

Certainly it's not a foolproof way to determine, say, when
a file has finished being written (a common enough request
on the Python list).

> 1. My first Dilema was trying to work out a way to consider all these 
> events as just 1 event.  Is there a flag for this? 

No. You'll need to do some sort of state machine such as
you've outlined below.

I ended up writing
> some special filters to filter out all the extra events that follow an 
> initial event up untill some condition is met. but I'm wondering if 
> there is an easy way to determine when a write operation has actually 
> finished? or when a write operation first STARTS. Nothing more.

> 2. Secondly and more importantly.   Events go missing.  Sometimes i get 
> a 'file deleted' event followed by a 'file created' event when i save a 
> file, but sometimes i just get a 'file created' event with no 'file 
> deleted' event preceding it. Both times i saved the file in exactly the 
> same way.  And it appears to be very random when it chooses to skip out 
> on not reporting the 'file deleted' event. 

Not that I have an answer, but do you have a repeatable code
snippet which illustrates this? I'd like to try it on a different
machine - viz, mine - to see if it's environmental.

 > Any ideas as to why some events appear to go missing?  Is
 > "ReadDirectoryChangesW " prone to inaccuracy's.
 > I have tried having
 > rather large heap sizes and that does not appear to help.

I've not used this routine all that much, but my own and other
peoples' experience points to buffer size as being the cause
of lost events. That said, I don't know of any rule-of-thumb
which indicates what might be a good size, and you've already
tried growing it somewhat.

Have you tried searching Google Groups for ReadDirectoryChangesW?
It's almost certainly worth it, because unless there's an issue
with the Python wrapper causing event-loss, it must be something
in the routine itself.

TJG
_______________________________________________
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to