File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -245,15 +245,19 @@ def get_replica_connections(self):
245245 ValueError: If the `mode` is neither Sentinel nor Cluster.
246246 """
247247 # decide if it's Sentinel or cluster
248- mode = self .connection .execute_command ("info" )['redis_mode' ]
248+ try :
249+ mode = self .connection .execute_command ("info" )['redis_mode' ]
250+ except Exception as e :
251+ raise Exception (f"Failed to get Redis mode: { e } " )
252+
249253 if hasattr (self , 'sentinel' ) and self .sentinel is not None :
250254 replica_hostnames = self .sentinel .discover_slaves (service_name = self .service_name )
251- return [(host , port ) for host , port in replica_hostnames ]
255+ return [(host , int ( port ) ) for host , port in replica_hostnames ]
252256 elif mode == "cluster" :
253257 data = self .connection .cluster_nodes ()
254- return [(flag ['hostname' ], ip_port .split (':' )[1 ]) for ip_port , flag in data .items () if 'slave' in flag ["flags" ]]
258+ return [(flag ['hostname' ], int ( ip_port .split (':' )[1 ])) for ip_port , flag in data .items () if 'slave' in flag ["flags" ] and flag [ "hostname " ]]
255259 else :
256- raise ValueError (f"Unsupported Redis mode: { redis_mode } " )
260+ raise ValueError (f"Unsupported Redis mode: { mode } " )
257261
258262
259263
You can’t perform that action at this time.
0 commit comments