feat: catch errors on do_ping (#14250)

This commit is contained in:
Beto Dealmeida
2021-04-21 15:43:40 -07:00
committed by GitHub
parent 70cfb7752c
commit 5d3191bb61
2 changed files with 31 additions and 2 deletions

View File

@@ -73,7 +73,11 @@ class TestConnectionDatabaseCommand(BaseCommand):
username = self._actor.username if self._actor is not None else None
engine = database.get_sqla_engine(user_name=username)
with closing(engine.raw_connection()) as conn:
if not engine.dialect.do_ping(conn):
try:
alive = engine.dialect.do_ping(conn)
except Exception: # pylint: disable=broad-except
alive = False
if not alive:
raise DBAPIError(None, None, None)
# Log succesful connection test with engine