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


Python PollingObserver.is_alive方法代码示例

本文整理汇总了Python中watchdog.observers.polling.PollingObserver.is_alive方法的典型用法代码示例。如果您正苦于以下问题:Python PollingObserver.is_alive方法的具体用法?Python PollingObserver.is_alive怎么用?Python PollingObserver.is_alive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在watchdog.observers.polling.PollingObserver的用法示例。


在下文中一共展示了PollingObserver.is_alive方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: folderObserver

# 需要导入模块: from watchdog.observers.polling import PollingObserver [as 别名]
# 或者: from watchdog.observers.polling.PollingObserver import is_alive [as 别名]
def folderObserver(pathStructure, dbPath):

    logging = DefaultLogger()

    if pathStructure == None or pathStructure['inBox'] == None:
        message = 'Watch: Unable to run as pathStructure is undefined'
        logging.debug(message)
        return
    
    event_handler = singleFileWatcher(pathStructure, dbPath)
    observer = PollingObserver()
    observer.schedule(event_handler, pathStructure['inBox'], recursive=False)
    observer.start()

    try:
        while True and observer.is_alive():
            time.sleep(1)
    except KeyboardInterrupt:
        observer.stop()
    observer.join()
开发者ID:patrickcusack,项目名称:BWF,代码行数:22,代码来源:watchprocess.py

示例2: getenv

# 需要导入模块: from watchdog.observers.polling import PollingObserver [as 别名]
# 或者: from watchdog.observers.polling.PollingObserver import is_alive [as 别名]
                    datefmt='%Y-%m-%d %H:%M:%S',
                    stream=sys.stdout)

GEOSERVER_DATA_DIR = getenv('GEOSERVER_DATA_DIR', '/etc/geoserver')
POLLING_INTERVAL = int(getenv('POLLING_INTERVAL', '5'))
FILE_BLACKLIST = getenv('FILE_BLACKLIST', '.log')


def sig_handler(signum, frame):
    """See signal callback registration: :py:func:`signal.signal`.
    This callback performs a clean shutdown when a SIGINT/SIGTERM is received.
    """
    logging.info('Received stop signal from signal: %i' % signum)
    observer.stop()

# Wire in signal handlers for SIGINT/SIGTERM
signal.signal(signal.SIGINT, sig_handler)
signal.signal(signal.SIGTERM, sig_handler)

# Initialize OS agnostic PollingObserver and handle schedule withGeoServerFileSystemEventHandler.
# This plays nicely with the lack of inotify support over NFS.
event_handler = GeoServerFileSystemEventHandler(POLLING_INTERVAL, FILE_BLACKLIST)
observer = PollingObserver(POLLING_INTERVAL)
observer.schedule(event_handler, GEOSERVER_DATA_DIR, recursive=True)
observer.start()

# Join for a second and then check thread life.
# This ensures exceptions within thread bubble up and cause process shutdown.
while observer.is_alive():
    observer.join(1)
开发者ID:AppliedIS,项目名称:dcos-geoserver,代码行数:32,代码来源:geoserver_watch.py


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