directorymonitor.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:irida-miseq-uploader 作者: phac-nml 项目源码 文件源码
def monitor_directory(directory):
    """Starts monitoring the specified directory in a background thread. File events
    will be passed to the `CompletedJobInfoEventHandler`.

    Arguments:
        directory: the directory to monitor.
    """
    observer = Observer()

    logging.info("Getting ready to monitor directory {}".format(directory))
    event_handler = CompletedJobInfoEventHandler()
    observer.schedule(event_handler, directory, recursive=True)

    def stop_monitoring(*args, **kwargs):
        """Tells watchdog to stop watching the directory when the newly processed run
        was discovered."""
        logging.info("Halting monitoring on directory because run was discovered.")
        observer.stop()
        observer.join()

    pub.subscribe(stop_monitoring, SettingsDialog.settings_closed_topic)
    pub.subscribe(stop_monitoring, DirectoryMonitorTopics.new_run_observed)
    pub.subscribe(stop_monitoring, DirectoryMonitorTopics.shut_down_directory_monitor)

    observer.start()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号