Skip to content

Commit 9e57796

Browse files
committed
make some sqlalchemy config options explicit (and not dependent on external specification) because they fundamentally change behaviors
1 parent e47ca86 commit 9e57796

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/server/_config.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,16 @@
1111
MAX_COMPATIBILITY_RESULTS = int(3650)
1212

1313
SQLALCHEMY_DATABASE_URI = os.environ.get("SQLALCHEMY_DATABASE_URI", "sqlite:///test.db")
14-
SQLALCHEMY_ENGINE_OPTIONS = json.loads(os.environ.get("SQLALCHEMY_ENGINE_OPTIONS", "{}"))
14+
15+
# defaults
16+
SQLALCHEMY_ENGINE_OPTIONS = {
17+
"pool_pre_ping": True, # enable ping test for validity of recycled pool connections on connect() calls
18+
"pool_recycle": 5 # seconds after which a recycled pool connection is considered invalid
19+
}
20+
# update with overrides of defaults or additions from external configs
21+
SQLALCHEMY_ENGINE_OPTIONS.update(
22+
json.loads(os.environ.get("SQLALCHEMY_ENGINE_OPTIONS", "{}")))
23+
1524
SECRET = os.environ.get("FLASK_SECRET", "secret")
1625
URL_PREFIX = os.environ.get("FLASK_PREFIX", "/")
1726

0 commit comments

Comments
 (0)