Exemple #1
0
 def get_conf_watchers(self):
     """
     Sets up monitoring of data manager related config files.
     These are the data_manager_conf.xml and shed_data_manager_conf.xml files
     as well as any loc file in the tool-data directory.
     """
     conf_watchers = []
     conf_watchers.extend([
         (get_tool_conf_watcher(lambda: reload_data_managers(self.app)),
          filename) for filename in util.listify(self.filename) if filename
     ])
     if self.app.config.shed_data_manager_config_file:
         conf_watchers.append(
             (get_tool_conf_watcher(lambda: reload_data_managers(self.app)),
              self.app.config.shed_data_manager_config_file))
     [watcher.watch_file(filename) for watcher, filename in conf_watchers]
     tool_data_watcher = get_tool_data_dir_watcher(
         self.app.tool_data_tables, self.app.config)
     tool_data_watcher.watch_directory(self.app.config.tool_data_path)
     if self.app.config.shed_tool_data_path:
         tool_data_watcher.watch_directory(
             self.app.config.shed_tool_data_path)
     conf_watchers.append(
         (tool_data_watcher, self.app.tool_data_tables.tool_data_path))
     return [watcher for watcher, filename in conf_watchers]
Exemple #2
0
 def get_conf_watchers(self):
     conf_watchers = []
     conf_watchers.extend([(get_tool_conf_watcher(lambda: reload_data_managers(self.app)), filename) for filename in util.listify(self.filename) if filename])
     if self.app.config.shed_data_manager_config_file:
         conf_watchers.append((get_tool_conf_watcher(lambda: reload_data_managers(self.app)), self.app.config.shed_data_manager_config_file))
     [watcher.watch_file(filename) for watcher, filename in conf_watchers]
     return [watcher for watcher, filename in conf_watchers]
Exemple #3
0
 def get_conf_watchers(self):
     conf_watchers = []
     conf_watchers.extend([
         (get_tool_conf_watcher(lambda: reload_data_managers(self.app)),
          filename) for filename in util.listify(self.filename) if filename
     ])
     if self.app.config.shed_data_manager_config_file:
         conf_watchers.append(
             (get_tool_conf_watcher(lambda: reload_data_managers(self.app)),
              self.app.config.shed_data_manager_config_file))
     [watcher.watch_file(filename) for watcher, filename in conf_watchers]
     return [watcher for watcher, filename in conf_watchers]
 def __init__(self, app, start_thread=True):
     self.app = app
     # ToolConfWatcher objects will watch the tool_cache if the tool_cache is passed into get_tool_conf_watcher.
     # Watching the tool_cache means removing outdated items from the tool_cache.
     # Only the reload_toolbox callback will re-populate the cache, so we pass the tool_cache only to the ToolConfWatcher that
     # watches regular tools.
     # If there are multiple ToolConfWatcher objects for the same handler or web process a race condition occurs between the two cache_cleanup functions.
     # If the reload_data_managers callback wins, the cache will miss the tools that had been removed from the cache
     # and will be blind to further changes in these tools.
     self.tool_config_watcher = get_tool_conf_watcher(
         reload_callback=lambda: reload_toolbox(self.app),
         tool_cache=self.app.tool_cache)
     self.data_manager_config_watcher = get_tool_conf_watcher(
         reload_callback=lambda: reload_data_managers(self.app))
     self.tool_data_watcher = get_tool_data_dir_watcher(
         self.app.tool_data_tables, config=self.app.config)
     self.tool_watcher = get_tool_watcher(self, app.config)
     if getattr(self.app, 'is_job_handler', False):
         self.job_rule_watcher = get_watcher(app.config,
                                             'watch_job_rules',
                                             monitor_what_str='job rules')
     else:
         self.job_rule_watcher = get_watcher(app.config, '__invalid__')
     if start_thread:
         self.start()
 def __init__(self, app):
     self.app = app
     # ToolConfWatcher objects will watch the tool_cache if the tool_cache is passed into get_tool_conf_watcher.
     # Watching the tool_cache means removing outdated items from the tool_cache.
     # Only the reload_toolbox callback will re-populate the cache, so we pass the tool_cache only to the ToolConfWatcher that
     # watches regular tools.
     # If there are multiple ToolConfWatcher objects for the same handler or web process a race condition occurs between the two cache_cleanup functions.
     # If the reload_data_managers callback wins, the cache will miss the tools that had been removed from the cache
     # and will be blind to further changes in these tools.
     self.tool_config_watcher = get_tool_conf_watcher(reload_callback=lambda: reload_toolbox(self.app), tool_cache=self.app.tool_cache)
     self.data_manager_config_watcher = get_tool_conf_watcher(reload_callback=lambda: reload_data_managers(self.app))
     self.tool_data_watcher = get_tool_data_dir_watcher(self.app.tool_data_tables, config=self.app.config)
     self.tool_watcher = get_tool_watcher(self, app.config)
     self.start()