def validate(self, max_retries=0):

        def _retry_on_exception(exc):
            LOG.warn("Engine connection (validate) failed due to '%s'", exc)
            if isinstance(exc, sa_exc.OperationalError) and \
               _is_db_connection_error(six.text_type(exc.args[0])):
                # We may be able to fix this by retrying...
                return True
            if isinstance(exc, (sa_exc.TimeoutError,
                                sa_exc.ResourceClosedError,
                                sa_exc.DisconnectionError)):
                # We may be able to fix this by retrying...
                return True
            # Other failures we likely can't fix by retrying...
            return False

        @retrying.retry(stop_max_attempt_number=max(0, int(max_retries)),
                        # Ensure that the 2 ** retry number
                        # is converted into milliseconds (thus why this
                        # multiplies by 1000.0) because thats what retrying
                        # lib. uses internally for whatever reason.
                        wait_exponential_multiplier=1000.0,
                        wrap_exception=False,
                        retry_on_exception=_retry_on_exception)
        def _try_connect(engine):
            # See if we can make a connection happen.
            #
            # NOTE(harlowja): note that even though we are connecting
            # once it does not mean that we will be able to connect in
            # the future, so this is more of a sanity test and is not
            # complete connection insurance.
            with contextlib.closing(engine.connect()):
                pass

        _try_connect(self._engine)
Performs basic **connection** validation of a sqlalchemy engine.
dataset/ETHPy150Open openstack/taskflow/taskflow/persistence/backends/impl_sqlalchemy.py/Connection.validate