Twisted's inotify watches for changes in a directory, reactor handles response in a different thread or process.
README.md: this file .gitignore: guess /src cmdline.py: a simple test script that simulates random processing latency dir_watch.py: the main file for this module tw_simple_proc.py: simple implementation of twisted's process protocol & interface to threadding
-
import the module
import dir_watch
-
create a watcher for a directory
my_notify = Dir_Watcher("/tmp/filewatch")
-
register one or more callback functions
def callbackfn(event, filepath): print filepath
my_notify.callbacks['create'] = callbackfn
-
turn on the listeners for the scripted events
my_notify.events = ['create']
-
run your reactor
reactor.run()
-
enjoy with family and friends.