fix(tests): isolate db state and stabilize voice runtime suite

This commit is contained in:
Yera All
2026-04-12 11:38:02 +05:00
parent e581d48c44
commit f2ece35588
6 changed files with 459 additions and 12 deletions
+13 -2
View File
@@ -599,8 +599,19 @@ def init_sql_schema() -> None:
if schema_management_mode() == "migrations":
validate_schema_migrations_applied()
elif not _BASE_SCHEMA_INITIALIZED:
Base.metadata.create_all(bind=engine)
_BASE_SCHEMA_INITIALIZED = True
for attempt in range(5):
try:
Base.metadata.create_all(bind=engine)
_BASE_SCHEMA_INITIALIZED = True
break
except OperationalError as exc:
message = str(exc).lower()
if "already exists" in message:
_BASE_SCHEMA_INITIALIZED = True
break
if "database is locked" not in message or attempt >= 4:
raise
time.sleep(0.25 * (attempt + 1))
for attempt in range(5):
try:
_apply_runtime_schema_compatibility()