Reputation: 31
I have to monitor for changes in a file and run relevant logic for any change event. I tried to use pyinotify package but after the first it stops notifying.
import pyinotify
class ModHandler(pyinotify.ProcessEvent):
# evt has useful properties, including pathname
def process_IN_CLOSE_WRITE(self, evt):
print('lior')
def registerChanges():
print('start run notifyer')
wm = pyinotify.WatchManager()
wm.add_watch("/home/vagrant/Desktop/test.txt", pyinotify.IN_CLOSE_WRITE)
handler = ModHandler()
notifier = pyinotify.Notifier(wm, handler)
notifier.loop()
registerChanges()
Thanks
Upvotes: 3
Views: 1942