이 IN_CLOSE_WRITE
에 IN_MODIFY
을 변경하려고 할 수 있습니다. 쓰기 가능한 파일이 닫히면 IN_CLOSE_WRITE
이벤트가 발생합니다. 파일을 복사하는 프로그램이 파일을 여러 번 닫지 않는 한 한 번만 발생해야합니다.
위의 변경 사항만으로 충분할 수 있지만 그렇지 않은 경우 this basic code 은 어떤 이벤트가 발생했는지 확인하는 데 매우 유용한 도구가 될 수 있습니다. 이를 사용하여 어떤 이벤트를 사용할지를 결정할 수 있어야합니다.
# Example: loops monitoring events forever.
#
import pyinotify
# Instanciate a new WatchManager (will be used to store watches).
wm = pyinotify.WatchManager()
# Associate this WatchManager with a Notifier (will be used to report and
# process events).
notifier = pyinotify.Notifier(wm)
# Add a new watch on /tmp for ALL_EVENTS.
wm.add_watch('/tmp', pyinotify.ALL_EVENTS)
# Loop forever and handle events.
notifier.loop()
당신은 확인해야합니다 [pyinotify에서이 문제] (https://github.com/seb-m/pyinotify/issues/45). IN_MODIFY 이벤트는 변경 사항이 파일에 기록되는 방식에 크게 영향을받습니다 (예 :'nano'는 2 개의 IN_MODIFY 이벤트를 트리거하고'sublime-text'는 어떤 이벤트도 발생시키지 않습니다) –