本文整理汇总了Python中pyinotify.ThreadedNotifier.process_events方法的典型用法代码示例。如果您正苦于以下问题:Python ThreadedNotifier.process_events方法的具体用法?Python ThreadedNotifier.process_events怎么用?Python ThreadedNotifier.process_events使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyinotify.ThreadedNotifier
的用法示例。
在下文中一共展示了ThreadedNotifier.process_events方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: watch_files
# 需要导入模块: from pyinotify import ThreadedNotifier [as 别名]
# 或者: from pyinotify.ThreadedNotifier import process_events [as 别名]
def watch_files(paths, mask):
"""
Vigila los ficheros de path y encola en queue los eventos producidos.
"""
watcher = WatchManager()
mask = (EventsCodes.ALL_FLAGS.get('IN_MODIFY', 0))
@asyncio.coroutine
def send_event(event):
"""Encola un evento en la cola."""
yield from event_queue.put(event)
notifier = ThreadedNotifier(
watcher,
lambda e: asyncio.get_event_loop().call_soon_threadsafe(
asyncio.async, send_event(e)))
for path in paths:
watcher.add_watch(path, mask, rec=True)
while True:
notifier.process_events()
event_present = yield from asyncio.get_event_loop().run_in_executor(
None, notifier.check_events)
if event_present:
notifier.read_events()
示例2: run
# 需要导入模块: from pyinotify import ThreadedNotifier [as 别名]
# 或者: from pyinotify.ThreadedNotifier import process_events [as 别名]
def run(self):
logging.info( 'Thead Watcher' )
wm = WatchManager()
notifier = ThreadedNotifier(wm, PTmp())
notifier.start()
wdd = wm.add_watch( account_dir, 4095, rec=True, auto_add=True) #ALL_EVENTS=>4095
logging.info('Add watch on folder ' + account_dir);
while True:
try:
notifier.process_events()
if notifier.check_events():
notifier.read_events()
except KeyboardInterrupt:
break