fix: add SQLite busy_timeout and fix regex escape warning

Set PRAGMA busy_timeout=30000 on SQLite connections to prevent
"database is locked" errors under concurrent access. Fix invalid
escape sequence in email regex by using raw string.
This commit is contained in:
russell@unturf.com 2026-02-26 22:32:11 -05:00
parent 738497ed2f
commit 1d5b473276
2 changed files with 12 additions and 3 deletions

View file

@ -1,4 +1,4 @@
from sqlalchemy import engine_from_config
from sqlalchemy import engine_from_config, event
from sqlalchemy.orm import sessionmaker
from sqlalchemy.orm import configure_mappers
import zope.sqlalchemy
@ -38,7 +38,16 @@ configure_mappers()
def get_engine(settings, prefix="sqlalchemy."):
return engine_from_config(settings, prefix)
engine = engine_from_config(settings, prefix)
if engine.url.get_backend_name() == "sqlite":
@event.listens_for(engine, "connect")
def set_sqlite_pragma(dbapi_conn, connection_record):
cursor = dbapi_conn.cursor()
cursor.execute("PRAGMA busy_timeout = 30000")
cursor.close()
return engine
def get_session_factory(engine):

View file

@ -39,7 +39,7 @@ def join_or_log_in(request):
OTP (one-time-password) tokens to email addresses to verify both the email
address & to authenticate the device displaying the challenge input field.
"""
_email_regex = re.compile("^[^@]+@[^@]+\.[^.@]+$")
_email_regex = re.compile(r"^[^@]+@[^@]+\.[^.@]+$")
raw_otp = request.params.get("raw-otp", "")
email = request.params.get("email", "")