mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
chore: remove dependency on func_timeout because LGPL (#31519)
This commit is contained in:
committed by
GitHub
parent
db11a2a308
commit
d8aba2f7e6
@@ -21,7 +21,6 @@ from typing import Any, Optional
|
||||
|
||||
from flask import current_app as app
|
||||
from flask_babel import gettext as _
|
||||
from func_timeout import func_timeout, FunctionTimedOut
|
||||
from sqlalchemy.engine import Engine
|
||||
from sqlalchemy.exc import DBAPIError, NoSuchModuleError
|
||||
|
||||
@@ -48,6 +47,7 @@ from superset.exceptions import (
|
||||
)
|
||||
from superset.extensions import event_logger
|
||||
from superset.models.core import Database
|
||||
from superset.utils import core as utils
|
||||
from superset.utils.ssh_tunnel import unmask_password_info
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -142,16 +142,14 @@ class TestConnectionDatabaseCommand(BaseCommand):
|
||||
|
||||
with database.get_sqla_engine(override_ssh_tunnel=ssh_tunnel) as engine:
|
||||
try:
|
||||
alive = func_timeout(
|
||||
app.config["TEST_DATABASE_CONNECTION_TIMEOUT"].total_seconds(),
|
||||
ping,
|
||||
args=(engine,),
|
||||
)
|
||||
time_delta = app.config["TEST_DATABASE_CONNECTION_TIMEOUT"]
|
||||
with utils.timeout(int(time_delta.total_seconds())):
|
||||
alive = ping(engine)
|
||||
except (sqlite3.ProgrammingError, RuntimeError):
|
||||
# SQLite can't run on a separate thread, so ``func_timeout`` fails
|
||||
# SQLite can't run on a separate thread, so ``utils.timeout`` fails
|
||||
# RuntimeError catches the equivalent error from duckdb.
|
||||
alive = engine.dialect.do_ping(engine)
|
||||
except FunctionTimedOut as ex:
|
||||
except SupersetTimeoutException as ex:
|
||||
raise SupersetTimeoutException(
|
||||
error_type=SupersetErrorType.CONNECTION_DATABASE_TIMEOUT,
|
||||
message=(
|
||||
|
||||
Reference in New Issue
Block a user