I'm using pyinotify.notifier
to keep track of changes in a text file.
When I get an specific change in it, I want to break the notifier loop. By using notifier.stop()
seems to not work.
Here is what I'm trying to do:
class ModHandler(pyinotify.ProcessEvent):
def process_IN_MODIFY(self, evt):
#... Do Stuff
if "Expected change":
#break notifier loop
if __name__ == "__main__":
handler = ModHandler()
wm = pyinotify.WatchManager()
notifier = pyinotify.Notifier(wm, handler)
wdd = wm.add_watch('example.file', pyinotify.IN_MODIFY)
notifier.loop()
#when finished the loop, do more stuff
How can break the thread loop and return to the main program?
The documentation states that:
notifier.loop()
The call to this method is blocking until we typec-c
(sigint)
So that's what you need to do. Send a sigint signal. Some ways of doing that: