当前位置: 首页>>代码示例>>Python>>正文


Python Notifier.coalesce_events方法代码示例

本文整理汇总了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()
开发者ID:dead5,项目名称:ninja-ide,代码行数:35,代码来源:linux.py

示例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()
开发者ID:soone,项目名称:docker-rsync,代码行数:9,代码来源:pyrsync.py

示例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()
开发者ID:ading2016,项目名称:My_Repo,代码行数:10,代码来源:notify.py


注:本文中的pyinotify.Notifier.coalesce_events方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。