in aws_advanced_python_wrapper/failover_plugin.py [0:0]
def execute(self, target: type, method_name: str, execute_func: Callable, *args: Any, **kwargs: Any) -> Any:
self._is_in_transaction = self._plugin_service.is_in_transaction
if not self._enable_failover_setting or self._can_direct_execute(method_name):
return execute_func()
if self._is_closed and not self._allowed_on_closed_connection(method_name):
self._invalid_invocation_on_closed_connection()
try:
if self._requires_update_topology(method_name):
self._update_topology(False)
return execute_func()
except Exception as ex:
logger.debug("FailoverPlugin.DetectedException", str(ex))
if self._last_exception != ex and self._should_exception_trigger_connection_switch(ex):
self._invalidate_current_connection()
if self._plugin_service.current_host_info is not None:
self._plugin_service.set_availability(
self._plugin_service.current_host_info.aliases, HostAvailability.UNAVAILABLE)
self._pick_new_connection()
self._last_exception = ex
raise AwsWrapperError(Messages.get_formatted("FailoverPlugin.DetectedException", str(ex))) from ex