Reputation: 143064
I want to be able to detect whenever new files are created or existing files are modified or deleted within a given directory tree (or set of trees). The brute force way to do this would be to just rescan the tree looking for changes, but I'm looking for a more "interrupt driven" solution where the file system tells my code what changed when it changes, rather than my code having to "poll" by continuously scanning through thousands of files looking for changes.
A way to do this in Python is preferred, but if I have to write a native module in C that's ok as a last resort.
Upvotes: 2
Views: 4447
Reputation: 1358
pyinotify is IMHO the only way to get system changes without scanning the directory.
Upvotes: 8
Reputation: 10274
twisted.internet.inotify
! It's much more useful to have an event loop attached than just free-floating inotify. Using twisted also gives you filepath
for free, which is a nice library for more easily manipulating file paths in python.
Upvotes: 8