views:

20

answers:

1

I am trying to watch a directory, and is looking for file modifications. Thinking of using pyinotify. Problem is that while using IN_MODIFY event to check for a file change, it triggers quite a number of events if I am copying even a small file of say 12 MB to the directory over a network.

I dont want to handle so many triggers. I want to only trigger a single event, after the file is copied. How do I achieve that?

Any Pyinotify gurus can help

+1  A: 

Try changing IN_MODIFY to IN_CLOSE_WRITE. An IN_CLOSE_WRITE event occurs when a writable file is closed. That should happen only once, unless the program that is copying the file chooses to close the file multiple times.

The above change is probably all you need, but if not, this basic code can be a very useful tool for seeing what events occur when. With it, you should be able to determine what event to use.

unutbu