def create_client(self, server): kwargs = parse_connection_kwargs( server, db=self.db, password=self.password, socket_timeout=self.socket_timeout, socket_connect_timeout=self.socket_connect_timeout, ) # Hack to make this work with SSL properly client_kwargs = kwargs.copy() if 'connection_class' in client_kwargs: client_kwargs['ssl'] = True del client_kwargs['connection_class'] client = redis.Redis(**client_kwargs) kwargs.update( parser_class=self.parser_class, connection_pool_class=self.connection_pool_class, connection_pool_class_kwargs=self.connection_pool_class_kwargs, ) if 'connection_class' in kwargs and not 'connection_class' in kwargs[ 'connection_pool_class_kwargs']: kwargs['connection_pool_class_kwargs'][ 'connection_class'] = kwargs['connection_class'] connection_pool = pool.get_connection_pool(client, **kwargs) client.connection_pool = connection_pool return client
def create_client(self, server): kwargs = parse_connection_kwargs( server, db=self.db, password=self.password, socket_timeout=self.socket_timeout, socket_connect_timeout=self.socket_connect_timeout, ) client = redis.Redis(**kwargs) kwargs.update( parser_class=self.parser_class, connection_pool_class=self.connection_pool_class, connection_pool_class_kwargs=self.connection_pool_class_kwargs, ) connection_pool = pool.get_connection_pool(client, **kwargs) client.connection_pool = connection_pool return client
def create_client(self, server): kwargs = { 'db': self.db, 'password': self.password, } if '://' in server: client = redis.Redis.from_url( server, parser_class=self.parser_class, **kwargs ) unix_socket_path = client.connection_pool.connection_kwargs.get('path') kwargs.update( client.connection_pool.connection_kwargs, unix_socket_path=unix_socket_path, ) else: unix_socket_path = None if ':' in server: host, port = server.rsplit(':', 1) try: port = int(port) except (ValueError, TypeError): raise ImproperlyConfigured("Port value must be an integer") else: host, port = None, None unix_socket_path = server kwargs.update( host=host, port=port, unix_socket_path=unix_socket_path, ) client = redis.Redis(**kwargs) kwargs.update( parser_class=self.parser_class, connection_pool_class=self.connection_pool_class, connection_pool_class_kwargs=self.connection_pool_class_kwargs, ) connection_pool = pool.get_connection_pool(client, **kwargs) client.connection_pool = connection_pool return client
def create_client(self, server): kwargs = { 'db': self.db, 'password': self.password, } if '://' in server: client = redis.Redis.from_url(server, parser_class=self.parser_class, **kwargs) unix_socket_path = client.connection_pool.connection_kwargs.get( 'path') kwargs.update( client.connection_pool.connection_kwargs, unix_socket_path=unix_socket_path, ) else: unix_socket_path = None if ':' in server: host, port = server.rsplit(':', 1) try: port = int(port) except (ValueError, TypeError): raise ImproperlyConfigured("Port value must be an integer") else: host, port = None, None unix_socket_path = server kwargs.update( host=host, port=port, unix_socket_path=unix_socket_path, ) client = redis.Redis(**kwargs) kwargs.update( parser_class=self.parser_class, connection_pool_class=self.connection_pool_class, connection_pool_class_kwargs=self.connection_pool_class_kwargs, ) connection_pool = pool.get_connection_pool(client, **kwargs) client.connection_pool = connection_pool return client
def create_client(self, server): kwargs = parse_connection_kwargs( server, db=self.db, password=self.password, socket_timeout=self.socket_timeout, socket_connect_timeout=self.socket_connect_timeout, ) # remove socket-related connection arguments if kwargs.get('ssl', False): del kwargs['socket_timeout'] del kwargs['socket_connect_timeout'] del kwargs['unix_socket_path'] client = redis.Redis(**kwargs) kwargs.update( parser_class=self.parser_class, connection_pool_class=self.connection_pool_class, connection_pool_class_kwargs=self.connection_pool_class_kwargs, ) connection_pool = pool.get_connection_pool(client, **kwargs) client.connection_pool = connection_pool return client