sentinel.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:asgi_redis 作者: django 项目源码 文件源码
def _get_service_names(self):
        """
        Get a list of service names from Sentinel. Tries Sentinel hosts until one succeeds; if none succeed,
        raises a ConnectionError.
        """
        master_info = None
        connection_errors = []
        for sentinel in self._sentinel.sentinels:
            # Unfortunately, redis.sentinel.Sentinel does not support sentinel_masters, so we have to step
            # through all of its connections manually
            try:
                master_info = sentinel.sentinel_masters()
                break
            except (redis.ConnectionError, redis.TimeoutError) as e:
                connection_errors.append("Failed to connect to {}: {}".format(sentinel, e))
                continue
        if master_info is None:
            raise redis.ConnectionError(
                "Could not get master info from sentinel\n{}.".format("\n".join(connection_errors)))
        return list(master_info.keys())

    ### Connection handling ####
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号