0
텍스트 파일의 변경 사항을 추적하기 위해 pyinotify.notifier
을 사용하고 있습니다.pyinotify 알리미 루프를 끊으십시오.
특정 변경 사항이 발생하면 알리미 루프를 중단하고 싶습니다. 사용하여 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
어떻게 스레드 루프를 중단하고 메인 프로그램으로 돌아갈 수 있습니다? 우리가 c-c
(SIGINT)를 입력 할 때까지
notifier.loop()
는이 방법의 호출이
은 그래서 당신이해야 할 무엇 차단 :
그것은했다. 'os.kill (os.getpid(), signal.SIGINT)'를 추가하고 루프를 완료했습니다. 당신의 도움을 주셔서 감사합니다. – MSO