Return the handler as a named tuple.

    The named tuple attributes are 'host', 'port', 'signum'.
    Return None when no handler has been registered.
517651
def get_handler():
    
    host, port, signum = _pdbhandler._registered()
    if signum:
        return Handler(host if host else DFLT_ADDRESS[0].encode(),
                       port if port else DFLT_ADDRESS[1], signum)
1247128
def get_message_handler(self, message_handlers):
        
        encoder = self.options.encoder
        try:
            return message_handlers[encoder]
        except KeyError:
            raise NotImplementedError('No RequestHandler defined for given encoder (%s).' % encoder)
1274424
def http_handler(name, logname, host, url, method="GET"):
    

    return wrap_log_handler(logging.handlers.HTTPHandler(
        host, url, method=method))
728862
def handler(self):
        """"""
        if self._handler is None:
            self._handler = self.HTTPSClientAuthHandler(key=self._keyfile,
                                                        cert=self._certificatefile)
        return self._handler
1364300
def u2handlers(self):
        
        handlers = []
        handlers.append(u2.ProxyHandler(self.proxy))
        return handlers
1357881
def _create_handler(self, config):
        
        if config is None:
            raise ValueError('No handler config to create handler from.')

        if 'name' not in config:
            raise ValueError('Handler name is required.')

        handler_name = config['name']
        # try to create handler
        module_name = handler_name.rsplit('.', 1)[0]
        class_name = handler_name.rsplit('.', 1)[-1]
        module = import_module(module_name)
        handler_class = getattr(module, class_name)
        instance = handler_class(**config)

        return instance
871725
def _commit_hostname_handler(self, cmd):
        """"""
        current_prompt = self.device.find_prompt().strip()
        terminating_char = current_prompt[-1]
        pattern = r"[>#{}]\s*$".format(terminating_char)
        # Look exclusively for trailing pattern that includes '#' and '>'
        output = self.device.send_command_expect(cmd, expect_string=pattern)
        # Reset base prompt in case hostname changed
        self.device.set_base_prompt()
        return output
553097
def get_handler(self):
        

        gcl_client = gcl_logging.Client(
            project=self.project_id, credentials=self.credentials)
        handler = gcl_handlers.CloudLoggingHandler(
            gcl_client,
            resource=self.resource,
            labels={
                'resource_id': self.instance_id,
                'resource_project': self.project_id,
                'resource_zone': self.zone,
                'resource_host': self.hostname
            })
        handler.setFormatter(self.get_formatter())
        self._set_worker_thread_level()
        return handler
1222531
def signal_handler_mapping(self):
    """"""
    # Could use an enum here, but we never end up doing any matching on the specific signal value,
    # instead just iterating over the registered signals to set handlers, so a dict is probably
    # better.
    return {
      signal.SIGINT: self.handle_sigint,
      signal.SIGQUIT: self.handle_sigquit,
      signal.SIGTERM: self.handle_sigterm,
    }
611370
def is_handler(cls, name, value):
        """"""
        signal_name = False
        config = None
        if callable(value) and hasattr(value, SPEC_CONTAINER_MEMBER_NAME):
                spec = getattr(value, SPEC_CONTAINER_MEMBER_NAME)
                if spec['kind'] == 'handler':
                    signal_name = spec['name']
                    config = spec['config']
        return signal_name, config
1003604
def get_request_handler(self):
        
        assert self.request_handler is not None, \
            'Please define a request_handler ' \
            ' for Endpoint: %s' % self.__class__.__name__

        return self.request_handler(self, **self.get_request_handler_params())
1043695
def get_handler(preferred_handler_name = nil)
      servers = %w[puma mongrel thin webrick]
      servers.unshift(preferred_handler_name) if preferred_handler_name
      
      handler = nil
      while((server_name = servers.shift) && handler === nil) do 
        begin
          handler = ::Rack::Handler.get(server_name)
        rescue LoadError
        rescue NameError
        end
      end
            
      if preferred_handler_name && server_name != preferred_handler_name
        puts "Handler '#{preferred_handler_name}' not found, using fallback ('#{server_name}')."
      end
      handler
    end
919957
def is_attrsignal_handler(descriptor, signal_name, cb, *, defer=False):
    
    try:
        handlers = get_magic_attr(cb)
    except AttributeError:
        return False

    return _attrsignal_spec(descriptor, signal_name, cb, defer) in handlers
718555
def _hack_namedtuple(cls):
    
    name = cls.__name__
    fields = cls._fields

    def __reduce__(self):
        return (_restore, (name, fields, tuple(self)))
    cls.__reduce__ = __reduce__
    cls._is_namedtuple_ = True
    return cls
533403
def sigusr2_handler(self, unused_signum, unused_frame):
        
        if self._sigusr1_handler_func is not None:
            self._sigusr2_handler_func(self.context)
330412
def _get_handler(self, node_id):
        """"""
        handler = self._get_attrs(node_id).get(self.HANDLER, self._default_handler)

        # Here we make sure the handler is an instance of `BasicNodeHandler` or inherited
        # types. While generally being bad Python practice, we still need it here as an
        # invalid handler can cause IDA to crash.
        if not isinstance(handler, BasicNodeHandler):
            idaapi.msg(("Invalid handler for node {}: {}. All handlers must inherit from"
                        "`BasicNodeHandler`.").format(node_id, handler))
            handler = self._default_handler
        return handler
550904
def _get_class_handlers(cls, signal_name, instance):
        
        handlers = cls._signal_handlers_sorted[signal_name]
        return [getattr(instance, hname) for hname in handlers]