File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -192,6 +192,19 @@ def default_lbp_factory():
192
192
return DCAwareRoundRobinPolicy ()
193
193
194
194
195
+ def _addrinfo_or_none (contact_point , port ):
196
+ """
197
+ A helper function that wraps socket.getaddrinfo and returns None
198
+ when it fails to, e.g. resolve one of the hostnames. Used to address
199
+ PYTHON-895.
200
+ """
201
+ try :
202
+ return socket .getaddrinfo (contact_point , port ,
203
+ socket .AF_UNSPEC , socket .SOCK_STREAM )
204
+ except (socket .error , socket .herror , socket .gaierror , socket .timeout ):
205
+ return None
206
+
207
+
195
208
class ExecutionProfile (object ):
196
209
load_balancing_policy = None
197
210
"""
@@ -824,8 +837,12 @@ def __init__(self,
824
837
825
838
self .port = port
826
839
827
- self .contact_points_resolved = [endpoint [4 ][0 ] for a in self .contact_points
828
- for endpoint in socket .getaddrinfo (a , self .port , socket .AF_UNSPEC , socket .SOCK_STREAM )]
840
+ self .contact_points_resolved = [
841
+ endpoint [4 ][0 ]
842
+ for point in self .contact_points
843
+ for endpoint in _addrinfo_or_none (point , self .port )
844
+ if endpoint is not None
845
+ ]
829
846
830
847
self .compression = compression
831
848
You can’t perform that action at this time.
0 commit comments