# 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()
尝试将
IN_MODIFY
更改为IN_CLOSE_WRITE
。 关闭可写文件时,IN_CLOSE_WRITE
事件发生。这应该只发生一次,除非复制文件的程序选择多次关闭该文件。在上面的更改可能是您需要的全部内容,但是如果不是的话,this basic code 可以是一个非常有用的工具来查看事件发生的时间。有了它,您应该能够确定要使用哪个事件。在
相关问题 更多 >
编程相关推荐