fix: sqlite3 lockout timeout (#3463)

sqlite3 lockout timeout
This commit is contained in:
ming 2024-08-21 08:11:19 -04:00 • committed by GitHub
commit ae99e6927e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 1 deletions

View file

@ -50,7 +50,10 @@ class DatabaseService(Service):
if self.settings_service.settings.database_url and self.settings_service.settings.database_url.startswith( if self.settings_service.settings.database_url and self.settings_service.settings.database_url.startswith(
"sqlite" "sqlite"
): ):
connect_args = {"check_same_thread": False} connect_args = {
"check_same_thread": False,
"timeout": self.settings_service.settings.db_connect_timeout,
}
else: else:
connect_args = {} connect_args = {}
try: try:

View file

@ -74,6 +74,8 @@ class Settings(BaseSettings):
max_overflow: int = 20 max_overflow: int = 20
"""The number of connections to allow that can be opened beyond the pool size. """The number of connections to allow that can be opened beyond the pool size.
If not provided, the default is 20.""" If not provided, the default is 20."""
db_connect_timeout: int = 20
"""The number of seconds to wait before giving up on a lock to released or establishing a connection to the database."""
# sqlite configuration # sqlite configuration
sqlite_pragmas: Optional[dict] = {"synchronous": "NORMAL", "journal_mode": "WAL"} sqlite_pragmas: Optional[dict] = {"synchronous": "NORMAL", "journal_mode": "WAL"}