@@ -181,17 +181,14 @@ def get_connection(self):
181
181
self .sniff_hosts ()
182
182
return self .connection_pool .get_connection ()
183
183
184
- def sniff_hosts (self , initial = False ):
184
+ def _get_sniff_data (self , initial = False ):
185
185
"""
186
- Obtain a list of nodes from the cluster and create a new connection
187
- pool using the information retrieved.
188
-
189
- To extract the node connection parameters use the ``nodes_to_host_callback``.
190
-
191
- :arg initial: flag indicating if this is during startup
192
- (``sniff_on_start``), ignore the ``sniff_timeout`` if ``True``
186
+ Perform the request to get sniffins information. Returns a list of
187
+ dictionaries (one per node) containing all the information from the
188
+ cluster.
193
189
"""
194
190
previous_sniff = self .last_sniff
191
+
195
192
try :
196
193
# reset last_sniff timestamp
197
194
self .last_sniff = time .time ()
@@ -213,9 +210,24 @@ def sniff_hosts(self, initial=False):
213
210
self .last_sniff = previous_sniff
214
211
raise
215
212
213
+ return list (node_info ['nodes' ].values ())
214
+
215
+
216
+ def sniff_hosts (self , initial = False ):
217
+ """
218
+ Obtain a list of nodes from the cluster and create a new connection
219
+ pool using the information retrieved.
220
+
221
+ To extract the node connection parameters use the ``nodes_to_host_callback``.
222
+
223
+ :arg initial: flag indicating if this is during startup
224
+ (``sniff_on_start``), ignore the ``sniff_timeout`` if ``True``
225
+ """
226
+ node_info = self ._get_sniff_data (initial )
227
+
216
228
hosts = []
217
229
address_key = self .connection_class .transport_schema + '_address'
218
- for n in node_info [ 'nodes' ]. values () :
230
+ for n in node_info :
219
231
host = {}
220
232
address = n .get (address_key , '' )
221
233
if '/' in address :
0 commit comments