MCPcopy Index your code
hub / github.com/apache/cassandra-python-driver / _reconnect_internal

Method _reconnect_internal

cassandra/cluster.py:3616–3645  ·  view source on GitHub ↗

Tries to connect to each host in the query plan until one succeeds or every attempt fails. If successful, a new Connection will be returned. Otherwise, :exc:`NoHostAvailable` will be raised with an "errors" arg that is a dict mapping host addresses to the ex

(self)

Source from the content-addressed store, hash-verified

3614 old.close()
3615
3616 def _reconnect_internal(self):
3617 """
3618 Tries to connect to each host in the query plan until one succeeds
3619 or every attempt fails. If successful, a new Connection will be
3620 returned. Otherwise, :exc:`NoHostAvailable` will be raised
3621 with an "errors" arg that is a dict mapping host addresses
3622 to the exception that was raised when an attempt was made to open
3623 a connection to that host.
3624 """
3625 errors = {}
3626 lbp = (
3627 self._cluster.load_balancing_policy
3628 if self._cluster._config_mode == _ConfigMode.LEGACY else
3629 self._cluster._default_load_balancing_policy
3630 )
3631
3632 for host in lbp.make_query_plan():
3633 try:
3634 return self._try_connect(host)
3635 except ConnectionException as exc:
3636 errors[str(host.endpoint)] = exc
3637 log.warning("[control connection] Error connecting to %s:", host, exc_info=True)
3638 self._cluster.signal_connection_failure(host, exc, is_host_addition=False)
3639 except Exception as exc:
3640 errors[str(host.endpoint)] = exc
3641 log.warning("[control connection] Error connecting to %s:", host, exc_info=True)
3642 if self._is_shutdown:
3643 raise DriverException("[control connection] Reconnection in progress during shutdown")
3644
3645 raise NoHostAvailable("Unable to connect to any servers", errors)
3646
3647 def _try_connect(self, host):
3648 """

Callers 3

connectMethod · 0.95
_reconnectMethod · 0.95
try_reconnectMethod · 0.80

Calls 5

_try_connectMethod · 0.95
DriverExceptionClass · 0.90
NoHostAvailableClass · 0.85
make_query_planMethod · 0.45

Tested by

no test coverage detected