fix(events): keep registration status reads nonblocking

This commit is contained in:
2026-10-01 13:35:17 +03:30
parent 962238c32c
commit f924fcc52e
16 changed files with 498 additions and 107 deletions

18
config/api_errors.py Normal file
View File

@@ -0,0 +1,18 @@
"""HTTP handling for recoverable database errors."""
from django.http import JsonResponse
def handle_database_operational_error(request, error):
"""Return a retryable response when PostgreSQL rejects a lock wait."""
cause = error.__cause__
while cause is not None:
if getattr(cause, "sqlstate", None) == "55P03" or getattr(cause, "pgcode", None) == "55P03":
response = JsonResponse(
{"detail": "درخواست به‌دلیل شلوغی موقت پایگاه داده انجام نشد؛ کمی بعد دوباره تلاش کنید."},
status=503,
)
response["Retry-After"] = "2"
return response
cause = cause.__cause__
raise error