def is_network_exception()

in aws_advanced_python_wrapper/utils/mysql_exception_handler.py [0:0]


    def is_network_exception(self, error: Optional[Exception] = None, sql_state: Optional[str] = None) -> bool:
        if isinstance(error, QueryTimeoutError):
            return True

        if isinstance(error, InterfaceError):
            if error.errno in self._NETWORK_ERRORS:
                return True

            if sql_state is None and error.sqlstate is not None:
                sql_state = error.sqlstate

        if sql_state is not None and (sql_state.startswith("08") or sql_state.startswith("HY")):
            # Connection exceptions may also be returned as a generic error
            # e.g. 2013 (HY000): Lost connection to MySQL server during query
            return True

        if isinstance(error, DatabaseError):
            if error.errno in self._NETWORK_ERRORS:
                return True
            if error.msg is not None and self._UNAVAILABLE_CONNECTION in error.msg:
                return True

            if len(error.args) == 1:
                return self._UNAVAILABLE_CONNECTION in error.args[0]

        return False