Produce an "optimized" version of handler for the dispatcher to
    limit reference lookups.
518381
def optimize_layout_handler(rule, handler):
    

    def runner(walk, dispatcher, node):
        yield LayoutChunk(rule, handler, node)

    return runner
447935
public static void replaceDefaultHandler(Handler handler) {
    Logger rootlogger = LogManager.getLogManager().getLogger("");
    for(Handler h : rootlogger.getHandlers()) {
      if(h instanceof CLISmartHandler) {
        rootlogger.removeHandler(h);
      }
    }
    addHandler(handler);
  }
377847
def get_handler_class(ext):
    """"""

    if ext in _extensions_map:
        format = _extensions_map[ext]
    else:
        raise ValueError("Unknown format for %s extension." % ext)

    if format in _handler_map:
        hc = _handler_map[format]
        return hc
    else:
        matches = difflib.get_close_matches(format, _handler_map.keys())
        raise ValueError("Unknown Handler for format %s, close matches: %s"
                         % (format, str(matches)))
1278796
public static HandlerReference newRef(
            ComponentType component, Method method,
            int priority, HandlerScope filter) {
        if (handlerTracking.isLoggable(Level.FINE)) {
            return new VerboseHandlerReference(
                component, method, priority, filter);
        } else {
            return new HandlerReference(component, method, priority, filter);
        }
    }
164893
def select(self, *args, **kwargs):
        """"""
        try:
            return super(PatroniSequentialThreadingHandler, self).select(*args, **kwargs)
        except ValueError as e:
            raise select.error(9, str(e))
1095315
def dispatch(args = {})
    rjr_method = args[:rjr_method]

    # *note* not using concurrent access protection,
    # assumes all handlers/enviroments are registered
    # before first dispatch occurs
    handler     = handler_for(rjr_method)
    environment = env_for(rjr_method)

    return Result.method_not_found(rjr_method) if handler.nil?

    request = Request.new args.merge(:rjr_handler  => handler)

    # set request environment
    request.set_env(environment) unless environment.nil?

    begin
      retval = request.handle
      request.result  = Result.new(:result => retval)

    rescue Exception => e
      warning = "Exception Raised in #{rjr_method} handler #{e}"
      RJR::Logger.warn [warning] + e.backtrace

      request.result = Result.new(:error_code  => -32000,
                                  :error_msg   => e.to_s,
                                  :error_class => e.class)
    end

    store_request request
    return request.result
  end
265037
def dispatch():
        
        aliases = SignalDispatcher.signals.keys()

        for alias in aliases:
            handlers = SignalDispatcher.handlers.get(alias)
            signal = SignalDispatcher.signals.get(alias)

            if signal is None or handlers.__len__() == 0:
                continue

            for handler in handlers:
                signal.connect(handler)
54669
def _unregisterHandler(self, handler, shutdown=True):
        
        if handler in self._handlers:
            self._handlers.remove(handler)
            self._logger.removeHandler(handler)
            if shutdown:
                try:
                    handler.close()
                except KeyError:
                    # Depending on the Python version, it's possible for this call
                    # to fail most likely because some logging module objects get
                    # garbage collected before the VSGLogger object is.
                    pass
472489
def post_dispatch(self):
        
        middleware = sort_by_priority(self, reverse=True)
        return tuple(m.post_dispatch for m in middleware if hasattr(m, 'post_dispatch'))
959477
def _dispatcher(self, connection, event):
        
        log.debug("_dispatcher: %s", event.type)

        def do_nothing(connection, event):
            return None
        method = getattr(self, "on_" + event.type, do_nothing)
        method(connection, event)
38438
def register_handler(alias: str, handler: callable):
        
        if SignalDispatcher.handlers.get(alias) is None:
            SignalDispatcher.handlers[alias] = [handler]
        else:
            SignalDispatcher.handlers.get(alias).append(handler)
497187
function setBeforeRouteChangeHandler(handler) {
            if (null == handler) {
                return _beforeRouteChange;
            }
            else {
                var oldHandler = _beforeRouteChange;
                _beforeRouteChange = handler;
                return oldHandler;
            }
        }
1108743
def _resolve_registered(self, event_handler, full_config) -> typing.Generator:
        
        for record in self._registered:
            filter_ = record.resolve(self._dispatcher, event_handler, full_config)
            if filter_:
                yield filter_

        if full_config:
            raise NameError('Invalid filter name(s): \'' + '\', '.join(full_config.keys()) + '\'')
265919
private static void callback(long handle) {
        final C4DatabaseObserver obs = REVERSE_LOOKUP_TABLE.get(handle);
        if (obs != null && obs.listener != null) { obs.listener.callback(obs, obs.context); }
    }
1231264
def add_result_handler(self, handler):
        
        self._result_handlers.append(handler)
        # Reset sorted handlers
        if self._sorted_handlers:
            self._sorted_handlers = None
1022000
def dispatch(self, env):
        

        path = filter(None, env['PATH_INFO'].split('/'))

        handler = getattr(self, 'handle_%s' % path[0], None)
        if not handler:
            return '404 Not Found', '%(PATH_INFO)s not found' % env

        return handler(env)
755565
public <V> V executeAndFetch(ResultSetHandler<V> handler) {
        try (ResultSet rs = executeQuery()) {
            return handler.apply(rs);
        } catch (SQLException ex) {
            throw new ApplicationException(Code.BACKEND_ERROR, ex);
        }
    }