Skip to content

Commit 64e1139

Browse files
Use endpoint instead od Host in _try_connect
1 parent f3e0c62 commit 64e1139

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

cassandra/cluster.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -838,8 +838,8 @@ def default_retry_policy(self, policy):
838838
Using ssl_options without ssl_context is deprecated and will be removed in the
839839
next major release.
840840
841-
An optional dict which will be used as kwargs for ``ssl.SSLContext.wrap_socket``
842-
when new sockets are created. This should be used when client encryption is enabled
841+
An optional dict which will be used as kwargs for ``ssl.SSLContext.wrap_socket``
842+
when new sockets are created. This should be used when client encryption is enabled
843843
in Cassandra.
844844
845845
The following documentation only applies when ssl_options is used without ssl_context.
@@ -1086,10 +1086,10 @@ def default_retry_policy(self, policy):
10861086
"""
10871087
Specifies a server-side timeout (in seconds) for all internal driver queries,
10881088
such as schema metadata lookups and cluster topology requests.
1089-
1089+
10901090
The timeout is enforced by appending `USING TIMEOUT <timeout>` to queries
10911091
executed by the driver.
1092-
1092+
10931093
- A value of `0` disables explicit timeout enforcement. In this case,
10941094
the driver does not add `USING TIMEOUT`, and the timeout is determined
10951095
by the server's defaults.
@@ -1717,7 +1717,7 @@ def connect(self, keyspace=None, wait_for_all_pools=False):
17171717
self.contact_points, self.protocol_version)
17181718
self.connection_class.initialize_reactor()
17191719
_register_cluster_shutdown(self)
1720-
1720+
17211721
self._add_resolved_hosts()
17221722

17231723
try:
@@ -3534,7 +3534,7 @@ def _set_new_connection(self, conn):
35343534
if old:
35353535
log.debug("[control connection] Closing old connection %r, replacing with %r", old, conn)
35363536
old.close()
3537-
3537+
35383538
def _connect_host_in_lbp(self):
35393539
errors = {}
35403540
lbp = (
@@ -3545,13 +3545,13 @@ def _connect_host_in_lbp(self):
35453545

35463546
for host in lbp.make_query_plan():
35473547
try:
3548-
return (self._try_connect(host), None)
3548+
return (self._try_connect(host.endpoint), None)
35493549
except Exception as exc:
35503550
errors[str(host.endpoint)] = exc
35513551
log.warning("[control connection] Error connecting to %s:", host, exc_info=True)
35523552
if self._is_shutdown:
35533553
raise DriverException("[control connection] Reconnection in progress during shutdown")
3554-
3554+
35553555
return (None, errors)
35563556

35573557
def _reconnect_internal(self):
@@ -3575,31 +3575,31 @@ def _reconnect_internal(self):
35753575
(conn, errors) = self._connect_host_in_lbp()
35763576
if conn is not None:
35773577
return conn
3578-
3578+
35793579
raise NoHostAvailable("Unable to connect to any servers", errors)
35803580

3581-
def _try_connect(self, host):
3581+
def _try_connect(self, endpoint):
35823582
"""
35833583
Creates a new Connection, registers for pushed events, and refreshes
35843584
node/token and schema metadata.
35853585
"""
3586-
log.debug("[control connection] Opening new connection to %s", host)
3586+
log.debug("[control connection] Opening new connection to %s", endpoint)
35873587

35883588
while True:
35893589
try:
3590-
connection = self._cluster.connection_factory(host.endpoint, is_control_connection=True)
3590+
connection = self._cluster.connection_factory(endpoint, is_control_connection=True)
35913591
if self._is_shutdown:
35923592
connection.close()
35933593
raise DriverException("Reconnecting during shutdown")
35943594
break
35953595
except ProtocolVersionUnsupported as e:
3596-
self._cluster.protocol_downgrade(host.endpoint, e.startup_version)
3596+
self._cluster.protocol_downgrade(endpoint, e.startup_version)
35973597
except ProtocolException as e:
35983598
# protocol v5 is out of beta in C* >=4.0-beta5 and is now the default driver
35993599
# protocol version. If the protocol version was not explicitly specified,
36003600
# and that the server raises a beta protocol error, we should downgrade.
36013601
if not self._cluster._protocol_version_explicit and e.is_beta_protocol_error:
3602-
self._cluster.protocol_downgrade(host.endpoint, self._cluster.protocol_version)
3602+
self._cluster.protocol_downgrade(endpoint, self._cluster.protocol_version)
36033603
else:
36043604
raise
36053605

0 commit comments

Comments
 (0)