From: Mike Bayer Date: Fri, 17 Apr 2026 20:13:53 +0000 (-0400) Subject: handle asyncpg InternalClientError X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=1281c2f778446d03ccec8ea43983edb0b6f694f7;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git handle asyncpg InternalClientError Fixed issue where the asyncpg driver could throw an insufficiently-handled exception ``InternalClientError`` under some circumstances, leading to connections not being properly marked as invalidated. Fixes: #13241 References: https://github.com/MagicStack/asyncpg/issues/1069 Change-Id: Iaaf551b3d7b062cce62e13b441161583a484615f (cherry picked from commit 70de8780239972233fe2b7b4121251698bbf19ca) --- diff --git a/doc/build/changelog/unreleased_20/13241.rst b/doc/build/changelog/unreleased_20/13241.rst new file mode 100644 index 0000000000..3b129450d2 --- /dev/null +++ b/doc/build/changelog/unreleased_20/13241.rst @@ -0,0 +1,9 @@ +.. change:: + :tags: bug, postgresql + :tickets: 13241 + + Fixed issue where the asyncpg driver could throw an insufficiently-handled + exception ``InternalClientError`` under some circumstances, leading to + connections not being properly marked as invalidated. + + diff --git a/lib/sqlalchemy/dialects/postgresql/asyncpg.py b/lib/sqlalchemy/dialects/postgresql/asyncpg.py index 616bc467f1..d0b10550cd 100644 --- a/lib/sqlalchemy/dialects/postgresql/asyncpg.py +++ b/lib/sqlalchemy/dialects/postgresql/asyncpg.py @@ -990,6 +990,9 @@ class AsyncAdapt_asyncpg_dbapi: class InternalServerError(InternalError): pass + class InternalClientError(InternalError): + pass + class InvalidCachedStatementError(NotSupportedError): def __init__(self, message): super().__init__( @@ -1014,6 +1017,7 @@ class AsyncAdapt_asyncpg_dbapi: asyncpg.exceptions.InterfaceError: self.InterfaceError, asyncpg.exceptions.InvalidCachedStatementError: self.InvalidCachedStatementError, # noqa: E501 asyncpg.exceptions.InternalServerError: self.InternalServerError, + asyncpg.exceptions.InternalClientError: self.InternalClientError, } def Binary(self, value):