This commit is contained in:
2026-10-23 18:28:52 +03:00
parent 396d149849
commit 3d33f0807f
5 changed files with 57 additions and 11 deletions
+7 -2
View File
@@ -4,7 +4,7 @@ from pathlib import Path
from psycopg import errors
from psycopg.rows import dict_row
from psycopg_pool import ConnectionPool
from psycopg_pool import ConnectionPool, PoolTimeout
MIGRATIONS_DIR = Path(__file__).resolve().parent / 'migrations'
@@ -38,7 +38,10 @@ class Store:
min_size=1,
max_size=10,
timeout=5.0,
kwargs={'row_factory': dict_row},
kwargs={
'row_factory': dict_row,
'options': '-c statement_timeout=5000 -c lock_timeout=2000',
},
open=True,
)
store = cls(pool)
@@ -94,6 +97,8 @@ class Store:
)
except errors.UniqueViolation:
raise ApiError(409, 'conflict', 'Username already exists') from None
except (errors.Error, PoolTimeout):
raise ApiError(503, 'unavailable', 'Service unavailable') from None
return {
'id': user_id,
'username': username,