def load_handlers(config, handler_names):
    log = logging.getLogger('diamond')

    handlers = []

    if isinstance(handler_names, basestring):
        handler_names = [handler_names]

    for handler in handler_names:
        log.debug('Loading Handler %s', handler)
        try:
            # Load Handler Class
            cls = load_dynamic_class(handler, Handler)
            cls_name = cls.__name__

            # Initialize Handler config
            handler_config = configobj.ConfigObj()
            # Merge default Handler default config
            handler_config.merge(config['handlers']['default'])
            # Check if Handler config exists
            if cls_name in config['handlers']:
                # Merge Handler config section
                handler_config.merge(config['handlers'][cls_name])

            # Check for config file in config directory
            if 'handlers_config_path' in config['server']:
                configfile = os.path.join(
                    config['server']['handlers_config_path'],
                    cls_name) + '.conf'
                if os.path.exists(configfile):
                    # Merge Collector config file
                    handler_config.merge(configobj.ConfigObj(configfile))

            # Initialize Handler class
            h = cls(handler_config)
            handlers.append(h)

        except (ImportError, SyntaxError):
            # Log Error
            log.warning("Failed to load handler %s. %s",
                        handler,
                        traceback.format_exc())
            continue

    return handlers
Test that commands can be sent to a specific instance.
dataset/ETHPy150Open BrightcoveOS/Diamond/src/diamond/utils/classes.py/load_handlers--crossover with--dataset/ETHPy150Open weblabdeusto/weblabdeusto/server/src/test/unit/experiments/archimedes/test_archimedes.py/TestArchimedes.test_explicit_instance_commands