summaryrefslogtreecommitdiff
path: root/redis/asyncio/sentinel.py
diff options
context:
space:
mode:
Diffstat (limited to 'redis/asyncio/sentinel.py')
-rw-r--r--redis/asyncio/sentinel.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/redis/asyncio/sentinel.py b/redis/asyncio/sentinel.py
index c3c0f91..9147ed8 100644
--- a/redis/asyncio/sentinel.py
+++ b/redis/asyncio/sentinel.py
@@ -254,10 +254,12 @@ class Sentinel(AsyncSentinelCommands):
Returns a pair (address, port) or raises MasterNotFoundError if no
master is found.
"""
+ collected_errors = list()
for sentinel_no, sentinel in enumerate(self.sentinels):
try:
masters = await sentinel.sentinel_masters()
- except (ConnectionError, TimeoutError):
+ except (ConnectionError, TimeoutError) as e:
+ collected_errors.append(f"{sentinel} - {e!r}")
continue
state = masters.get(service_name)
if state and self.check_master_state(state, service_name):
@@ -267,7 +269,11 @@ class Sentinel(AsyncSentinelCommands):
self.sentinels[0],
)
return state["ip"], state["port"]
- raise MasterNotFoundError(f"No master found for {service_name!r}")
+
+ error_info = ""
+ if len(collected_errors) > 0:
+ error_info = f" : {', '.join(collected_errors)}"
+ raise MasterNotFoundError(f"No master found for {service_name!r}{error_info}")
def filter_slaves(
self, slaves: Iterable[Mapping]