如何使用python连续监视文件中的更改
我必须监视文件中的更改,并为任何更改事件运行相关逻辑。 我尝试使用pyinotify包,但在第一次使用后,它停止通知如何使用python连续监视文件中的更改,python,linux,pyinotify,Python,Linux,Pyinotify,我必须监视文件中的更改,并为任何更改事件运行相关逻辑。 我尝试使用pyinotify包,但在第一次使用后,它停止通知 import pyinotify class ModHandler(pyinotify.ProcessEvent): # evt has useful properties, including pathname def process_IN_CLOSE_WRITE(self, evt): print('lior') def regis
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()
谢谢检查您正在运行的python版本。可能与