[#717] Add a pool_recycle database engine arg to avoid losing connection with database

This commit is contained in:
Théophile Diot 2023-10-25 12:26:28 +01:00
parent 762092e5e9
commit 0975de1238
No known key found for this signature in database
GPG key ID: 248FEA4BAE400D06

View file

@ -88,7 +88,7 @@ class Database:
self.database_uri = sqlalchemy_string
error = False
engine_kwargs = {"future": True, "poolclass": None if pool else SingletonThreadPool, "pool_pre_ping": True}
engine_kwargs = {"future": True, "poolclass": None if pool else SingletonThreadPool, "pool_pre_ping": True, "pool_recycle": 1800}
try:
self.__sql_engine = create_engine(sqlalchemy_string, **engine_kwargs)
@ -169,7 +169,6 @@ class Database:
_exit(1)
session = self.__sql_session()
session.expire_on_commit = False
try:
yield session