I am using Celery with pyinotify to monitor changes of modules, but the function of Celery does not work. I want to figure out why. So I test the pyinotify module and the question appear.
I follow the tutorial of pyinotify and write some codes:
import pyinotify
wm = pyinotify.WatchManager()
mask = pyinotify.IN_MODIFY | pyinotify.IN_ATTRIB
class EventHandler(pyinotify.ProcessEvent):
def process_IN_MODIFY(self, event):
print "IN_MODIFY:", event.pathname
def process_IN_ATTRIB(self, event):
print "IN_ATTRIB:", event.pathname
handler = EventHandler()
notifier = pyinotify.Notifier(wm, handler)
wdd = wm.add_watch('/home/mp/Public/testfile', mask, rec=True)
notifier.loop()
I change '/home/mp/Public/testfile' twice with gedit and CommandLine echo :
/usr/bin/python2.7 /home/mp/PycharmProjects/pywork/mpyinotify/inotify.py
IN_ATTRIB: /home/mp/Public/testfile
IN_ATTRIB: /home/mp/Public/testfile
Then I continue to modify the file , but there is no more echo no matter how many times you change the file.
pyinotify 0.9.6