#NEWLINE# def __init__( self , servers , hash_method = 'crc32' , sentinel = None , strict_redis = False ) : #NEWLINE# #INDENT# self . nodes = [ ] #NEWLINE# self . connections = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# self . pool = None #NEWLINE# servers = format_servers ( servers ) #NEWLINE# if sentinel : #NEWLINE# #INDENT# sentinel = Sentinel ( sentinel [ 'hosts' ] , socket_timeout = sentinel . get ( 'socket_timeout' , 1 ) ) #NEWLINE# #UNINDENT# for server_config in servers : #NEWLINE# #INDENT# name = server_config . pop ( 'name' ) #NEWLINE# server_config [ 'max_connections' ] = int ( server_config . get ( 'max_connections' , 100 ) ) #NEWLINE# if ( name in self . connections ) : #NEWLINE# #INDENT# raise ValueError ( "server's name config must be unique" ) #NEWLINE# #UNINDENT# if sentinel : #NEWLINE# #INDENT# self . connections [ name ] = SentinelRedis ( sentinel , name ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if strict_redis : #NEWLINE# #INDENT# self . connections [ name ] = redis . StrictRedis ( ** server_config ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . connections [ name ] = redis . Redis ( ** server_config ) #NEWLINE# #UNINDENT# #UNINDENT# server_config [ 'name' ] = name #NEWLINE# self . nodes . append ( name ) #NEWLINE# #UNINDENT# self . ring = HashRing ( self . nodes , hash_method = hash_method )