I am experiencing the following situation:
- pyinotify monitors a file for IN_CLOSE_WRITE events
- I change something in the file and save it
- the event is triggered
- I read the file and see that it has no changes
Having tinkered with this a little bit, I noticed that it works fine when I am debugging. I set a breakpoint on the line that reads the file, thus adding a little delay. After that - the file is read and the changes are there.
So, it seems that adding a time.sleep(1)
, or delaying execution in some other way does the trick. Otherwise I receive a premature IN_CLOSE_WRITE event.
I wondered whether the event is triggered after the changes are committed and the file is closed, or before that. There seem to be no other relevant events after IN_CLOSE_WRITE. At the same time, the documentation is a little bit tricky:
use IN_CLOSE_WRITE because if emitted the all changes on the appropriate file are safely written inside the file
I filed a bug report about the wording in the FAQ, but in the meantime I would like to get some additional input on this matter. Is this supposed to happen? What are the "morally correct" ways of solving it?
All of this is happening on a Linux Mint 15 x64.