Skip to content

Commit f689cbc

Browse files
committed
feat: timeout
1 parent 2efad70 commit f689cbc

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

backend/apps/datasource/crud/datasource.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def get_ds(session: SessionDep, id: int):
4141

4242

4343
def check_status(session: SessionDep, ds: CoreDatasource, is_raise: bool = False):
44-
conn = get_engine(ds)
44+
conn = get_engine(ds, 5)
4545
try:
4646
with conn.connect() as connection:
4747
SQLBotLogUtil.info("success")

backend/apps/db/db.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ def get_uri_from_config(type: str, conf: DatasourceConf) -> str:
5252
return db_url
5353

5454

55-
def get_engine(ds: CoreDatasource) -> Engine:
55+
def get_engine(ds: CoreDatasource, timeout: int = 30) -> Engine:
5656
conf = DatasourceConf(**json.loads(aes_decrypt(ds.configuration))) if ds.type != "excel" else get_engine_config()
5757
if conf.timeout is None:
58-
conf.timeout = 30
58+
conf.timeout = timeout
5959
if ds.type == "pg" and (conf.dbSchema is not None and conf.dbSchema != ""):
6060
engine = create_engine(get_uri(ds),
6161
connect_args={"options": f"-c search_path={urllib.parse.quote(conf.dbSchema)}",

0 commit comments

Comments
 (0)