forked from mtusi2026/mtusi2026lab2
fixes
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user