korbit-ai[bot] commented on code in PR #32231: URL: https://github.com/apache/superset/pull/32231#discussion_r1958841384
########## superset/commands/database/utils.py: ########## @@ -17,15 +17,33 @@ from __future__ import annotations import logging +import sqlite3 +from contextlib import closing + +from flask import current_app as app +from sqlalchemy.engine import Engine from superset import security_manager from superset.databases.ssh_tunnel.models import SSHTunnel from superset.db_engine_specs.base import GenericDBException from superset.models.core import Database +from superset.utils.core import timeout logger = logging.getLogger(__name__) +def ping(engine: Engine) -> bool: + try: + time_delta = app.config["TEST_DATABASE_CONNECTION_TIMEOUT"] + with timeout(int(time_delta.total_seconds())): + with closing(engine.raw_connection()) as conn: + return engine.dialect.do_ping(conn) + except (sqlite3.ProgrammingError, RuntimeError): + # SQLite can't run on a separate thread, so ``utils.timeout`` fails + # RuntimeError catches the equivalent error from duckdb. + return engine.dialect.do_ping(engine) Review Comment: @Vitor-Avila Noted. So the exceptions being caught are expected and part of the original flow as you have moved the function. In this case, there is no need for logging those specific situations as they are handled appropriately. Thank you for the clarification. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For additional commands, e-mail: notifications-h...@superset.apache.org