本文整理汇总了Python中pyinotify.ThreadedNotifier.name方法的典型用法代码示例。如果您正苦于以下问题:Python ThreadedNotifier.name方法的具体用法?Python ThreadedNotifier.name怎么用?Python ThreadedNotifier.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyinotify.ThreadedNotifier
的用法示例。
在下文中一共展示了ThreadedNotifier.name方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: monitor
# 需要导入模块: from pyinotify import ThreadedNotifier [as 别名]
# 或者: from pyinotify.ThreadedNotifier import name [as 别名]
def monitor(filename, server):
"""Monitor the config file for changes and update the server's values when they do.
Using pyinotify, it checks the config file for changes and tells the
server to make changes when they occur. Starts and returns the
ThreadedNotifier that is created.
Keyword arguments:
filename -- the name of the file you want to monitor. Note that it won't actually monitor this file, but the directory it resides in.
server -- the EmailServer currently running, to pass the new values to when they're changed.
"""
logging.info('Monitoring {0} for changes'.format(filename))
wm = WatchManager()
notifier = ThreadedNotifier(wm, PClose(server, filename))
notifier.name = 'MonitorThread'
# we actually watch the folder to the file, otherwise the handle is lost every time the file is modified.
wm.add_watch(os.path.split(filename)[0], IN_CLOSE_WRITE, rec=True)
notifier.start()
return notifier