We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
SentinelConnectionPool. Error when working under uwsgi
It raises following exception:

```
redis.sentinel in get_master_address
AttributeError: 'int' object has no attribute 'discover_master'
```

The reason is `ConnectionPool._checkpid()` calls `__init__()` ([connection.py#L397](https://github.com/andymccurdy/redis-py/blob/7210906be09b969e5833de5a967178c4d6989f14/redis/connection.py#L397)) with 
`self.connection_class, self.max_connections`
instead
`self.service_name, self.sentinel_manager`.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `redis/sentinel.py`
Content:
```
1 import random
2 
3 from redis.client import StrictRedis
4 from redis.connection import ConnectionPool, Connection
5 from redis.exceptions import ConnectionError, ResponseError
6 from redis._compat import xrange, nativestr
7 
8 
9 class MasterNotFoundError(ConnectionError):
10     pass
11 
12 
13 class SlaveNotFoundError(ConnectionError):
14     pass
15 
16 
17 class SentinelManagedConnection(Connection):
18     def __init__(self, **kwargs):
19         self.connection_pool = kwargs.pop('connection_pool')
20         super(SentinelManagedConnection, self).__init__(**kwargs)
21 
22     def connect_to(self, address):
23         self.host, self.port = address
24         super(SentinelManagedConnection, self).connect()
25         if self.connection_pool.check_connection:
26             self.send_command('PING')
27             if nativestr(self.read_response()) != 'PONG':
28                 raise ConnectionError('PING failed')
29 
30     def connect(self):
31         if self._sock:
32             return  # already connected
33         if self.connection_pool.is_master:
34             self.connect_to(self.connection_pool.get_master_address())
35         else:
36             for slave in self.connection_pool.rotate_slaves():
37                 try:
38                     return self.connect_to(slave)
39                 except ConnectionError:
40                     continue
41             raise SlaveNotFoundError  # Never be here
42 
43 
44 class SentinelConnectionPool(ConnectionPool):
45     """
46     Sentinel backed connection pool.
47 
48     If ``check_connection`` flag is set to True, SentinelManagedConnection
49     sends a PING command right after establishing the connection.
50     """
51 
52     def __init__(self, service_name, sentinel_manager, **kwargs):
53         kwargs['connection_class'] = kwargs.get(
54             'connection_class', SentinelManagedConnection)
55         self.is_master = kwargs.pop('is_master', True)
56         self.check_connection = kwargs.pop('check_connection', False)
57         super(SentinelConnectionPool, self).__init__(**kwargs)
58         self.connection_kwargs['connection_pool'] = self
59         self.service_name = service_name
60         self.sentinel_manager = sentinel_manager
61         self.master_address = None
62         self.slave_rr_counter = None
63 
64     def get_master_address(self):
65         master_address = self.sentinel_manager.discover_master(
66             self.service_name)
67         if not self.is_master:
68             pass
69         elif self.master_address is None:
70             self.master_address = master_address
71         elif master_address != self.master_address:
72             self.disconnect()  # Master address changed
73         return master_address
74 
75     def rotate_slaves(self):
76         "Round-robin slave balancer"
77         slaves = self.sentinel_manager.discover_slaves(self.service_name)
78         if slaves:
79             if self.slave_rr_counter is None:
80                 self.slave_rr_counter = random.randint(0, len(slaves) - 1)
81             for _ in xrange(len(slaves)):
82                 self.slave_rr_counter = (
83                     self.slave_rr_counter + 1) % len(slaves)
84                 slave = slaves[self.slave_rr_counter]
85                 yield slave
86         # Fallback to the master connection
87         try:
88             yield self.get_master_address()
89         except MasterNotFoundError:
90             pass
91         raise SlaveNotFoundError('No slave found for %r' % (self.service_name))
92 
93 
94 class Sentinel(object):
95     """
96     Redis Sentinel cluster client
97 
98     >>> from redis.sentinel import Sentinel
99     >>> sentinel = Sentinel([('localhost', 26379)], socket_timeout=0.1)
100     >>> master = sentinel.master_for('mymaster', socket_timeout=0.1)
101     >>> master.set('foo', 'bar')
102     >>> slave = sentinel.slave_for('mymaster', socket_timeout=0.1)
103     >>> slave.get('foo')
104     'bar'
105 
106     ``sentinels`` is a list of sentinel nodes. Each node is represented by
107     a pair (hostname, port).
108 
109     Use ``socket_timeout`` to specify a timeout for sentinel clients.
110     It's recommended to use short timeouts.
111 
112     Use ``min_other_sentinels`` to filter out sentinels with not enough peers.
113     """
114 
115     def __init__(self, sentinels, password=None, socket_timeout=None,
116                  min_other_sentinels=0):
117         self.sentinels = [StrictRedis(hostname, port, password=password,
118                                       socket_timeout=socket_timeout)
119                           for hostname, port in sentinels]
120         self.min_other_sentinels = min_other_sentinels
121 
122     def check_master_state(self, state, service_name):
123         if not state['is_master'] or state['is_sdown'] or state['is_odown']:
124             return False
125         # Check if our sentinel doesn't see other nodes
126         if state['num-other-sentinels'] < self.min_other_sentinels:
127             return False
128         return True
129 
130     def discover_master(self, service_name):
131         """
132         Asks sentinel servers for the Redis master's address corresponding
133         to the service labeled ``service_name``.
134 
135         Returns a pair (address, port) or raises MasterNotFoundError if no
136         master is found.
137         """
138         for sentinel_no, sentinel in enumerate(self.sentinels):
139             try:
140                 masters = sentinel.sentinel_masters()
141             except ConnectionError:
142                 continue
143             state = masters.get(service_name)
144             if state and self.check_master_state(state, service_name):
145                 # Put this sentinel at the top of the list
146                 self.sentinels[0], self.sentinels[sentinel_no] = (
147                     sentinel, self.sentinels[0])
148                 return state['ip'], state['port']
149         raise MasterNotFoundError("No master found for %r" % (service_name,))
150 
151     def filter_slaves(self, slaves):
152         "Remove slaves that are in an ODOWN or SDOWN state"
153         slaves_alive = []
154         for slave in slaves:
155             if slave['is_odown'] or slave['is_sdown']:
156                 continue
157             slaves_alive.append((slave['ip'], slave['port']))
158         return slaves_alive
159 
160     def discover_slaves(self, service_name):
161         "Returns a list of alive slaves for service ``service_name``"
162         for sentinel in self.sentinels:
163             try:
164                 slaves = sentinel.sentinel_slaves(service_name)
165             except (ConnectionError, ResponseError):
166                 continue
167             slaves = self.filter_slaves(slaves)
168             if slaves:
169                 return slaves
170         return []
171 
172     def master_for(self, service_name, redis_class=StrictRedis,
173                    connection_pool_class=SentinelConnectionPool, **kwargs):
174         """
175         Returns a redis client instance for the ``service_name`` master.
176 
177         A SentinelConnectionPool class is used to retrive the master's
178         address before establishing a new connection.
179 
180         NOTE: If the master's address has changed, any cached connections to
181         the old master are closed.
182 
183         By default clients will be a redis.StrictRedis instance. Specify a
184         different class to the ``redis_class`` argument if you desire
185         something different.
186 
187         The ``connection_pool_class`` specifies the connection pool to use.
188         The SentinelConnectionPool will be used by default.
189 
190         All other arguments are passed directly to the SentinelConnectionPool.
191         """
192         kwargs['is_master'] = True
193         return redis_class(connection_pool=connection_pool_class(
194             service_name, self, **kwargs))
195 
196     def slave_for(self, service_name, redis_class=StrictRedis,
197                   connection_pool_class=SentinelConnectionPool, **kwargs):
198         """
199         Returns redis client instance for the ``service_name`` slave(s).
200 
201         A SentinelConnectionPool class is used to retrive the slave's
202         address before establishing a new connection.
203 
204         By default clients will be a redis.StrictRedis instance. Specify a
205         different class to the ``redis_class`` argument if you desire
206         something different.
207 
208         The ``connection_pool_class`` specifies the connection pool to use.
209         The SentinelConnectionPool will be used by default.
210 
211         All other arguments are passed directly to the SentinelConnectionPool.
212         """
213         kwargs['is_master'] = False
214         return redis_class(connection_pool=connection_pool_class(
215             service_name, self, **kwargs))
216
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/redis/sentinel.py b/redis/sentinel.py
--- a/redis/sentinel.py
+++ b/redis/sentinel.py
@@ -1,3 +1,4 @@
+import os
 import random
 
 from redis.client import StrictRedis
@@ -90,6 +91,14 @@
             pass
         raise SlaveNotFoundError('No slave found for %r' % (self.service_name))
 
+    def _checkpid(self):
+        if self.pid != os.getpid():
+            self.disconnect()
+            self.__init__(self.service_name, self.sentinel_manager,
+                          connection_class=self.connection_class,
+                          max_connections=self.max_connections,
+                          **self.connection_kwargs)
+
 
 class Sentinel(object):
     """

{"golden_diff": "diff --git a/redis/sentinel.py b/redis/sentinel.py\n--- a/redis/sentinel.py\n+++ b/redis/sentinel.py\n@@ -1,3 +1,4 @@\n+import os\n import random\n \n from redis.client import StrictRedis\n@@ -90,6 +91,14 @@\n             pass\n         raise SlaveNotFoundError('No slave found for %r' % (self.service_name))\n \n+    def _checkpid(self):\n+        if self.pid != os.getpid():\n+            self.disconnect()\n+            self.__init__(self.service_name, self.sentinel_manager,\n+                          connection_class=self.connection_class,\n+                          max_connections=self.max_connections,\n+                          **self.connection_kwargs)\n+\n \n class Sentinel(object):\n     \"\"\"\n", "issue": "SentinelConnectionPool. Error when working under uwsgi\nIt raises following exception:\n\n```\nredis.sentinel in get_master_address\nAttributeError: 'int' object has no attribute 'discover_master'\n```\n\nThe reason is `ConnectionPool._checkpid()` calls `__init__()` ([connection.py#L397](https://github.com/andymccurdy/redis-py/blob/7210906be09b969e5833de5a967178c4d6989f14/redis/connection.py#L397)) with \n`self.connection_class, self.max_connections`\ninstead\n`self.service_name, self.sentinel_manager`.\n\n", "before_files": [{"content": "import random\n\nfrom redis.client import StrictRedis\nfrom redis.connection import ConnectionPool, Connection\nfrom redis.exceptions import ConnectionError, ResponseError\nfrom redis._compat import xrange, nativestr\n\n\nclass MasterNotFoundError(ConnectionError):\n    pass\n\n\nclass SlaveNotFoundError(ConnectionError):\n    pass\n\n\nclass SentinelManagedConnection(Connection):\n    def __init__(self, **kwargs):\n        self.connection_pool = kwargs.pop('connection_pool')\n        super(SentinelManagedConnection, self).__init__(**kwargs)\n\n    def connect_to(self, address):\n        self.host, self.port = address\n        super(SentinelManagedConnection, self).connect()\n        if self.connection_pool.check_connection:\n            self.send_command('PING')\n            if nativestr(self.read_response()) != 'PONG':\n                raise ConnectionError('PING failed')\n\n    def connect(self):\n        if self._sock:\n            return  # already connected\n        if self.connection_pool.is_master:\n            self.connect_to(self.connection_pool.get_master_address())\n        else:\n            for slave in self.connection_pool.rotate_slaves():\n                try:\n                    return self.connect_to(slave)\n                except ConnectionError:\n                    continue\n            raise SlaveNotFoundError  # Never be here\n\n\nclass SentinelConnectionPool(ConnectionPool):\n    \"\"\"\n    Sentinel backed connection pool.\n\n    If ``check_connection`` flag is set to True, SentinelManagedConnection\n    sends a PING command right after establishing the connection.\n    \"\"\"\n\n    def __init__(self, service_name, sentinel_manager, **kwargs):\n        kwargs['connection_class'] = kwargs.get(\n            'connection_class', SentinelManagedConnection)\n        self.is_master = kwargs.pop('is_master', True)\n        self.check_connection = kwargs.pop('check_connection', False)\n        super(SentinelConnectionPool, self).__init__(**kwargs)\n        self.connection_kwargs['connection_pool'] = self\n        self.service_name = service_name\n        self.sentinel_manager = sentinel_manager\n        self.master_address = None\n        self.slave_rr_counter = None\n\n    def get_master_address(self):\n        master_address = self.sentinel_manager.discover_master(\n            self.service_name)\n        if not self.is_master:\n            pass\n        elif self.master_address is None:\n            self.master_address = master_address\n        elif master_address != self.master_address:\n            self.disconnect()  # Master address changed\n        return master_address\n\n    def rotate_slaves(self):\n        \"Round-robin slave balancer\"\n        slaves = self.sentinel_manager.discover_slaves(self.service_name)\n        if slaves:\n            if self.slave_rr_counter is None:\n                self.slave_rr_counter = random.randint(0, len(slaves) - 1)\n            for _ in xrange(len(slaves)):\n                self.slave_rr_counter = (\n                    self.slave_rr_counter + 1) % len(slaves)\n                slave = slaves[self.slave_rr_counter]\n                yield slave\n        # Fallback to the master connection\n        try:\n            yield self.get_master_address()\n        except MasterNotFoundError:\n            pass\n        raise SlaveNotFoundError('No slave found for %r' % (self.service_name))\n\n\nclass Sentinel(object):\n    \"\"\"\n    Redis Sentinel cluster client\n\n    >>> from redis.sentinel import Sentinel\n    >>> sentinel = Sentinel([('localhost', 26379)], socket_timeout=0.1)\n    >>> master = sentinel.master_for('mymaster', socket_timeout=0.1)\n    >>> master.set('foo', 'bar')\n    >>> slave = sentinel.slave_for('mymaster', socket_timeout=0.1)\n    >>> slave.get('foo')\n    'bar'\n\n    ``sentinels`` is a list of sentinel nodes. Each node is represented by\n    a pair (hostname, port).\n\n    Use ``socket_timeout`` to specify a timeout for sentinel clients.\n    It's recommended to use short timeouts.\n\n    Use ``min_other_sentinels`` to filter out sentinels with not enough peers.\n    \"\"\"\n\n    def __init__(self, sentinels, password=None, socket_timeout=None,\n                 min_other_sentinels=0):\n        self.sentinels = [StrictRedis(hostname, port, password=password,\n                                      socket_timeout=socket_timeout)\n                          for hostname, port in sentinels]\n        self.min_other_sentinels = min_other_sentinels\n\n    def check_master_state(self, state, service_name):\n        if not state['is_master'] or state['is_sdown'] or state['is_odown']:\n            return False\n        # Check if our sentinel doesn't see other nodes\n        if state['num-other-sentinels'] < self.min_other_sentinels:\n            return False\n        return True\n\n    def discover_master(self, service_name):\n        \"\"\"\n        Asks sentinel servers for the Redis master's address corresponding\n        to the service labeled ``service_name``.\n\n        Returns a pair (address, port) or raises MasterNotFoundError if no\n        master is found.\n        \"\"\"\n        for sentinel_no, sentinel in enumerate(self.sentinels):\n            try:\n                masters = sentinel.sentinel_masters()\n            except ConnectionError:\n                continue\n            state = masters.get(service_name)\n            if state and self.check_master_state(state, service_name):\n                # Put this sentinel at the top of the list\n                self.sentinels[0], self.sentinels[sentinel_no] = (\n                    sentinel, self.sentinels[0])\n                return state['ip'], state['port']\n        raise MasterNotFoundError(\"No master found for %r\" % (service_name,))\n\n    def filter_slaves(self, slaves):\n        \"Remove slaves that are in an ODOWN or SDOWN state\"\n        slaves_alive = []\n        for slave in slaves:\n            if slave['is_odown'] or slave['is_sdown']:\n                continue\n            slaves_alive.append((slave['ip'], slave['port']))\n        return slaves_alive\n\n    def discover_slaves(self, service_name):\n        \"Returns a list of alive slaves for service ``service_name``\"\n        for sentinel in self.sentinels:\n            try:\n                slaves = sentinel.sentinel_slaves(service_name)\n            except (ConnectionError, ResponseError):\n                continue\n            slaves = self.filter_slaves(slaves)\n            if slaves:\n                return slaves\n        return []\n\n    def master_for(self, service_name, redis_class=StrictRedis,\n                   connection_pool_class=SentinelConnectionPool, **kwargs):\n        \"\"\"\n        Returns a redis client instance for the ``service_name`` master.\n\n        A SentinelConnectionPool class is used to retrive the master's\n        address before establishing a new connection.\n\n        NOTE: If the master's address has changed, any cached connections to\n        the old master are closed.\n\n        By default clients will be a redis.StrictRedis instance. Specify a\n        different class to the ``redis_class`` argument if you desire\n        something different.\n\n        The ``connection_pool_class`` specifies the connection pool to use.\n        The SentinelConnectionPool will be used by default.\n\n        All other arguments are passed directly to the SentinelConnectionPool.\n        \"\"\"\n        kwargs['is_master'] = True\n        return redis_class(connection_pool=connection_pool_class(\n            service_name, self, **kwargs))\n\n    def slave_for(self, service_name, redis_class=StrictRedis,\n                  connection_pool_class=SentinelConnectionPool, **kwargs):\n        \"\"\"\n        Returns redis client instance for the ``service_name`` slave(s).\n\n        A SentinelConnectionPool class is used to retrive the slave's\n        address before establishing a new connection.\n\n        By default clients will be a redis.StrictRedis instance. Specify a\n        different class to the ``redis_class`` argument if you desire\n        something different.\n\n        The ``connection_pool_class`` specifies the connection pool to use.\n        The SentinelConnectionPool will be used by default.\n\n        All other arguments are passed directly to the SentinelConnectionPool.\n        \"\"\"\n        kwargs['is_master'] = False\n        return redis_class(connection_pool=connection_pool_class(\n            service_name, self, **kwargs))\n", "path": "redis/sentinel.py"}], "after_files": [{"content": "import os\nimport random\n\nfrom redis.client import StrictRedis\nfrom redis.connection import ConnectionPool, Connection\nfrom redis.exceptions import ConnectionError, ResponseError\nfrom redis._compat import xrange, nativestr\n\n\nclass MasterNotFoundError(ConnectionError):\n    pass\n\n\nclass SlaveNotFoundError(ConnectionError):\n    pass\n\n\nclass SentinelManagedConnection(Connection):\n    def __init__(self, **kwargs):\n        self.connection_pool = kwargs.pop('connection_pool')\n        super(SentinelManagedConnection, self).__init__(**kwargs)\n\n    def connect_to(self, address):\n        self.host, self.port = address\n        super(SentinelManagedConnection, self).connect()\n        if self.connection_pool.check_connection:\n            self.send_command('PING')\n            if nativestr(self.read_response()) != 'PONG':\n                raise ConnectionError('PING failed')\n\n    def connect(self):\n        if self._sock:\n            return  # already connected\n        if self.connection_pool.is_master:\n            self.connect_to(self.connection_pool.get_master_address())\n        else:\n            for slave in self.connection_pool.rotate_slaves():\n                try:\n                    return self.connect_to(slave)\n                except ConnectionError:\n                    continue\n            raise SlaveNotFoundError  # Never be here\n\n\nclass SentinelConnectionPool(ConnectionPool):\n    \"\"\"\n    Sentinel backed connection pool.\n\n    If ``check_connection`` flag is set to True, SentinelManagedConnection\n    sends a PING command right after establishing the connection.\n    \"\"\"\n\n    def __init__(self, service_name, sentinel_manager, **kwargs):\n        kwargs['connection_class'] = kwargs.get(\n            'connection_class', SentinelManagedConnection)\n        self.is_master = kwargs.pop('is_master', True)\n        self.check_connection = kwargs.pop('check_connection', False)\n        super(SentinelConnectionPool, self).__init__(**kwargs)\n        self.connection_kwargs['connection_pool'] = self\n        self.service_name = service_name\n        self.sentinel_manager = sentinel_manager\n        self.master_address = None\n        self.slave_rr_counter = None\n\n    def get_master_address(self):\n        master_address = self.sentinel_manager.discover_master(\n            self.service_name)\n        if not self.is_master:\n            pass\n        elif self.master_address is None:\n            self.master_address = master_address\n        elif master_address != self.master_address:\n            self.disconnect()  # Master address changed\n        return master_address\n\n    def rotate_slaves(self):\n        \"Round-robin slave balancer\"\n        slaves = self.sentinel_manager.discover_slaves(self.service_name)\n        if slaves:\n            if self.slave_rr_counter is None:\n                self.slave_rr_counter = random.randint(0, len(slaves) - 1)\n            for _ in xrange(len(slaves)):\n                self.slave_rr_counter = (\n                    self.slave_rr_counter + 1) % len(slaves)\n                slave = slaves[self.slave_rr_counter]\n                yield slave\n        # Fallback to the master connection\n        try:\n            yield self.get_master_address()\n        except MasterNotFoundError:\n            pass\n        raise SlaveNotFoundError('No slave found for %r' % (self.service_name))\n\n    def _checkpid(self):\n        if self.pid != os.getpid():\n            self.disconnect()\n            self.__init__(self.service_name, self.sentinel_manager,\n                          connection_class=self.connection_class,\n                          max_connections=self.max_connections,\n                          **self.connection_kwargs)\n\n\nclass Sentinel(object):\n    \"\"\"\n    Redis Sentinel cluster client\n\n    >>> from redis.sentinel import Sentinel\n    >>> sentinel = Sentinel([('localhost', 26379)], socket_timeout=0.1)\n    >>> master = sentinel.master_for('mymaster', socket_timeout=0.1)\n    >>> master.set('foo', 'bar')\n    >>> slave = sentinel.slave_for('mymaster', socket_timeout=0.1)\n    >>> slave.get('foo')\n    'bar'\n\n    ``sentinels`` is a list of sentinel nodes. Each node is represented by\n    a pair (hostname, port).\n\n    Use ``socket_timeout`` to specify a timeout for sentinel clients.\n    It's recommended to use short timeouts.\n\n    Use ``min_other_sentinels`` to filter out sentinels with not enough peers.\n    \"\"\"\n\n    def __init__(self, sentinels, password=None, socket_timeout=None,\n                 min_other_sentinels=0):\n        self.sentinels = [StrictRedis(hostname, port, password=password,\n                                      socket_timeout=socket_timeout)\n                          for hostname, port in sentinels]\n        self.min_other_sentinels = min_other_sentinels\n\n    def check_master_state(self, state, service_name):\n        if not state['is_master'] or state['is_sdown'] or state['is_odown']:\n            return False\n        # Check if our sentinel doesn't see other nodes\n        if state['num-other-sentinels'] < self.min_other_sentinels:\n            return False\n        return True\n\n    def discover_master(self, service_name):\n        \"\"\"\n        Asks sentinel servers for the Redis master's address corresponding\n        to the service labeled ``service_name``.\n\n        Returns a pair (address, port) or raises MasterNotFoundError if no\n        master is found.\n        \"\"\"\n        for sentinel_no, sentinel in enumerate(self.sentinels):\n            try:\n                masters = sentinel.sentinel_masters()\n            except ConnectionError:\n                continue\n            state = masters.get(service_name)\n            if state and self.check_master_state(state, service_name):\n                # Put this sentinel at the top of the list\n                self.sentinels[0], self.sentinels[sentinel_no] = (\n                    sentinel, self.sentinels[0])\n                return state['ip'], state['port']\n        raise MasterNotFoundError(\"No master found for %r\" % (service_name,))\n\n    def filter_slaves(self, slaves):\n        \"Remove slaves that are in an ODOWN or SDOWN state\"\n        slaves_alive = []\n        for slave in slaves:\n            if slave['is_odown'] or slave['is_sdown']:\n                continue\n            slaves_alive.append((slave['ip'], slave['port']))\n        return slaves_alive\n\n    def discover_slaves(self, service_name):\n        \"Returns a list of alive slaves for service ``service_name``\"\n        for sentinel in self.sentinels:\n            try:\n                slaves = sentinel.sentinel_slaves(service_name)\n            except (ConnectionError, ResponseError):\n                continue\n            slaves = self.filter_slaves(slaves)\n            if slaves:\n                return slaves\n        return []\n\n    def master_for(self, service_name, redis_class=StrictRedis,\n                   connection_pool_class=SentinelConnectionPool, **kwargs):\n        \"\"\"\n        Returns a redis client instance for the ``service_name`` master.\n\n        A SentinelConnectionPool class is used to retrive the master's\n        address before establishing a new connection.\n\n        NOTE: If the master's address has changed, any cached connections to\n        the old master are closed.\n\n        By default clients will be a redis.StrictRedis instance. Specify a\n        different class to the ``redis_class`` argument if you desire\n        something different.\n\n        The ``connection_pool_class`` specifies the connection pool to use.\n        The SentinelConnectionPool will be used by default.\n\n        All other arguments are passed directly to the SentinelConnectionPool.\n        \"\"\"\n        kwargs['is_master'] = True\n        return redis_class(connection_pool=connection_pool_class(\n            service_name, self, **kwargs))\n\n    def slave_for(self, service_name, redis_class=StrictRedis,\n                  connection_pool_class=SentinelConnectionPool, **kwargs):\n        \"\"\"\n        Returns redis client instance for the ``service_name`` slave(s).\n\n        A SentinelConnectionPool class is used to retrive the slave's\n        address before establishing a new connection.\n\n        By default clients will be a redis.StrictRedis instance. Specify a\n        different class to the ``redis_class`` argument if you desire\n        something different.\n\n        The ``connection_pool_class`` specifies the connection pool to use.\n        The SentinelConnectionPool will be used by default.\n\n        All other arguments are passed directly to the SentinelConnectionPool.\n        \"\"\"\n        kwargs['is_master'] = False\n        return redis_class(connection_pool=connection_pool_class(\n            service_name, self, **kwargs))\n", "path": "redis/sentinel.py"}]}