に変更IN_MODIFY
してみてくださいIN_CLOSE_WRITE
。書き込み可能なIN_CLOSE_WRITE
ファイルが閉じられると、イベントが発生します。ファイルをコピーしているプログラムがファイルを複数回閉じることを選択しない限り、これは1回だけ発生するはずです。
上記の変更はおそらく必要なすべてですが、そうでない場合、この基本的なコード
は、どのイベントがいつ発生するかを確認するための非常に便利なツールになります。これにより、使用するイベントを決定できるようになります。
# 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()