本文整理汇总了Python中pyinotify.Notifier.coalesce_events方法的典型用法代码示例。如果您正苦于以下问题:Python Notifier.coalesce_events方法的具体用法?Python Notifier.coalesce_events怎么用?Python Notifier.coalesce_events使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyinotify.Notifier
的用法示例。
在下文中一共展示了Notifier.coalesce_events方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: QNotifier
# 需要导入模块: from pyinotify import Notifier [as 别名]
# 或者: from pyinotify.Notifier import coalesce_events [as 别名]
class QNotifier(QThread):
def __init__(self, wm, processor):
self.event_queue = list()
self._processor = processor
self.notifier = Notifier(wm,
NinjaProcessEvent(self.event_queue.append))
self.notifier.coalesce_events(True)
self.keep_running = True
QThread.__init__(self)
def run(self):
while self.keep_running:
try:
self.notifier.process_events()
except OSError:
pass # OSError: [Errno 2] No such file or directory happens
e_dict = {}
while len(self.event_queue):
e_type, e_path = self.event_queue.pop(0)
e_dict.setdefault(e_path, []).append(e_type)
keys = e_dict.keys()
while len(keys):
key = keys.pop(0)
event = e_dict.pop(key)
if (ADDED in event) and (DELETED in event):
event = [e for e in event if e not in (ADDED, DELETED)]
for each_event in event:
self._processor(each_event, key)
if self.notifier.check_events():
self.notifier.read_events()
self.notifier.stop()
示例2: fsMonitor
# 需要导入模块: from pyinotify import Notifier [as 别名]
# 或者: from pyinotify.Notifier import coalesce_events [as 别名]
def fsMonitor(path="/data"):
wm = WatchManager()
mask = IN_DELETE | IN_MODIFY | IN_CREATE
notifier = Notifier(wm, EventHandler(), read_freq=10)
notifier.coalesce_events()
wm.add_watch(path, mask, rec=True, auto_add=True)
notifier.loop()
示例3: FSMonitor
# 需要导入模块: from pyinotify import Notifier [as 别名]
# 或者: from pyinotify.Notifier import coalesce_events [as 别名]
def FSMonitor(path='/root/wpf'):
wm = WatchManager()
mask = IN_DELETE | IN_MODIFY | IN_CREATE
notifier = Notifier(wm, EventHandler(),read_freq=10)
notifier.coalesce_events()
# 设置受监视的事件,这里只监视文件创建事件,(rec=True, auto_add=True)为递归处理
wm.add_watch(path,mask,rec=True, auto_add=True)
notifier.loop()