packages/django-dramatiq-postgres: reset db connections in raise_connection_error (#21577)

Co-authored-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
This commit is contained in:
João C. Fernandes
2026-04-14 13:20:23 +01:00
committed by GitHub
parent 8327b4d177
commit bbd0cb2521

View File

@@ -62,6 +62,10 @@ def raise_connection_error(func: Callable[P, R]) -> Callable[P, R]: # noqa: UP0
return func(*args, **kwargs) return func(*args, **kwargs)
except DATABASE_ERRORS as exc: except DATABASE_ERRORS as exc:
logger.warning("Database error encountered", exc=exc) logger.warning("Database error encountered", exc=exc)
try:
connections.close_all()
except DATABASE_ERRORS:
pass
raise ConnectionError(str(exc)) from exc # type: ignore[no-untyped-call] raise ConnectionError(str(exc)) from exc # type: ignore[no-untyped-call]
return wrapper return wrapper