我在用着pyinotify.notifier
用来跟踪文本文件中的更改。
当我得到一个特定的变化时,我想打破通知循环。通过使用notifier.stop()
似乎不起作用。
这是我正在尝试做的事情:
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
怎样才能打破线程循环并返回主程序?