Skip to content

Commit b49d1f6

Browse files
committed
feat: add datasource timeout
1 parent d66d21e commit b49d1f6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

backend/apps/db/engine.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
def get_engine_config():
1414
return DatasourceConf(username=settings.POSTGRES_USER, password=settings.POSTGRES_PASSWORD,
1515
host=settings.POSTGRES_SERVER, port=settings.POSTGRES_PORT, database=settings.POSTGRES_DB,
16-
dbSchema="public", timeout=30)
16+
dbSchema="public", timeout=30) # read engine config
1717

1818

1919
def get_engine_uri(conf: DatasourceConf):
@@ -23,7 +23,9 @@ def get_engine_uri(conf: DatasourceConf):
2323
def get_engine_conn():
2424
conf = get_engine_config()
2525
db_url = get_engine_uri(conf)
26-
engine = create_engine(db_url, connect_args={"options": f"-c search_path={conf.dbSchema}"}, pool_timeout=300,
26+
engine = create_engine(db_url,
27+
connect_args={"options": f"-c search_path={conf.dbSchema}", "connect_timeout": conf.timeout},
28+
pool_timeout=conf.timeout,
2729
pool_size=20,
2830
max_overflow=10)
2931
return engine

0 commit comments

Comments
 (0)