chrisjbillington / inotify_simple

A simple Python wrapper around inotify. No fancy bells and whistles, just a literal wrapper with ctypes.
BSD 2-Clause "Simplified" License
124 stars 22 forks source link

Extend doc to cover watching a file #19

Open chrisinmtown opened 4 years ago

chrisinmtown commented 4 years ago

Can inotify_simple watch a file? The documentation only mentions monitoring a directory, but the linux kernel call allows monitoring of directories OR files:

https://man7.org/linux/man-pages/man7/inotify.7.html

Maybe this is just a request to extend the documentation slightly :)

Thanks for listening

chrisjbillington commented 4 years ago

Yes, it can, it's just calling the underlying inotify functions fairly directly so it can do everything they can do. The example with a directory is just because there are more interesting events that can happen on a directory!

Point taken that this could be made more obvious in the documentation.

bulletmark commented 4 years ago

Just note that it often makes more sense to watch the directory and act on changes associated with the file name you want to watch. In particular, the file may not exist when you want to start watching it so the call will fail. Just watch the directory instead and action appropriately when that file name is added, deleted, or modified.

chrisinmtown commented 4 years ago

Thanks @bulletmark but my scenario is watching a configuration file published by Kubernetes from within a running container started by Kubernetes. If that file ain't there on start then nuthin' happens :)