def __new__(cls, classname, bases, classdict):
        _client_cls = bases[0]  # FIXME: Might not always be the first base.

        def __init__(self, host_provider, timeout=5000,
                     retry_policy=None, statsd_client=dummy_statsd,
                     socket_connection_timeout=None,
                     always_retry_on_new_host=False,
                     retry_count=3,
                     protocol_factory=DEFAULT_THRIFT_PROTOCOL_FACTORY,
                     is_ssl=False, validate=True, ca_certs=None,
                     failed_retry_policy_log_sample_rate=1.0):
            """Replacement of subclass constructor.

            Args:
                host_provider: A ``HostProvider`` to provide the list of
                    live hosts for the client to talk to.
                timeout: Timeout in milliseconds for connections.
                retry_policy: On what exception the request should be retried.
                socket_connection_timeout: timeout for establishing the
                    underlying socket connection for the first time. By
                    default, it is None, which will fallback to timeout
                    specified.
                always_retry_on_new_host: If set, always retry on a new host.
                retry_count: total number of tries of rpc.
                protocol_factory: the factory of the underlying protocol to
                                  be used for rpc.
                is_ssl: use SSL connection or not, default is False.
                validate: Set to False to disable SSL certificate validation.
                ca_certs: Filename to the Certificate Authority pem file.
                failed_retry_policy_log_sample_rate: sometimes the "failed retry policy
                becomes too overwhelming so you can set a logging
                 sample rate which ranges from [0, 1.0].
            """
            # Use expire_time of 0 for all thrift services, because the client
            # controls when to use a different endpoint.
            # Use retry_time of 0 because some requests are intrinsically
            # slow, we don't want to penalize the servers for this.
            self._host_selector = RandomHostSelector(
                host_provider, expire_time=0, retry_time=0)
            host_port_pair = self._host_selector.get_host()
            host, port = host_port_pair.split(":")
            self.host = host
            self.port = int(port)
            self.timeout = timeout
            self.is_ssl = is_ssl
            self.validate = validate
            self.ca_certs = ca_certs
            self.retry_policy = retry_policy
            self.retry_count = retry_count
            self.socket_connection_timeout = socket_connection_timeout
            self.always_retry_on_new_host = always_retry_on_new_host

            self.connected = False
            self.connected_at = 0
            self.requests_served = 0
            self.statsd_client = statsd_client
            self.protocol_factory = protocol_factory
            self.failed_retry_policy_log_sample_rate = failed_retry_policy_log_sample_rate

        classdict['__init__'] = __init__

        service_name = "Base"
        if _client_cls.__module__:
            service_name = _client_cls.__module__
            if service_name.split('.') > 0:
                service_name = service_name.split('.')[-1]

        # Wrap all methods.
        for method_name, method in getmembers(_client_cls, predicate=ismethod):
            # Ignore private methods.
            if method_name[0][0] == '_':
                continue
            # Create wrapper.
            classdict[method_name] = ensure_connection(
                service_name, method_name, method)

        return type.__new__(cls, classname, bases, classdict)
dataset/ETHPy150Open pinterest/kingpin/kingpin/thrift_utils/thrift_client_mixin.py/ThriftClientConnectionEnsured.__new__/original