What is the best way to make a spool in a directory with pyinotify?

913 views Asked by At

im trying to move every file in a directory to another when they are created. Maybe i could stop the daemon (pyinotify instance running) cleanly, and the original files continue to be created in the orig/spool directory.

I want to be processed after the daemon starts again. Maybe i can take advantage of the inotify kernel queues?

Thanks in advance

1

There are 1 answers

1
synthesizerpatel On

You don't really want to move them as they're created, but rather as they're closed. Once they're closed (and nobody has any open file handles on them), you can consider them 'complete' and you can move them without any surprises.

You'll probably be good if you look for a 'close_write' event. (Although that doesn't guarantee that the file contains data or new data, you'd have to verify a modify->close_write event. But 99.99% of the time, close_write will do the job.