From: hbusul Date: Mon, 29 Mar 2021 15:42:33 +0000 (-0400) Subject: accommodate new pg8000 disconnection exception X-Git-Tag: rel_1_4_4~8^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=42f29ae6525a5c5348c3ff2926607ec53eed5190;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git accommodate new pg8000 disconnection exception Modified the ``is_disconnect()`` handler for the pg8000 dialect, which now accommodates for a new ``InterfaceError`` emitted by pg8000 1.19.0. Pull request courtesy Hamdi Burak Usul. Fixes: #6099 Closes: #6150 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6150 Pull-request-sha: cd58836d3e19489d5203c02f7cc5f2f2d7c82a20 Change-Id: Ief942e53f6d90c48e8d77c70948fd46eb6c90dbd --- diff --git a/doc/build/changelog/unreleased_14/6099.rst b/doc/build/changelog/unreleased_14/6099.rst new file mode 100644 index 0000000000..5e715b9c57 --- /dev/null +++ b/doc/build/changelog/unreleased_14/6099.rst @@ -0,0 +1,8 @@ +.. change:: + :tags: bug, postgresql + :tickets: 6099 + + Modified the ``is_disconnect()`` handler for the pg8000 dialect, which now + accommodates for a new ``InterfaceError`` emitted by pg8000 1.19.0. Pull + request courtesy Hamdi Burak Usul. + diff --git a/lib/sqlalchemy/dialects/postgresql/pg8000.py b/lib/sqlalchemy/dialects/postgresql/pg8000.py index 6e73182727..cda0bc9415 100644 --- a/lib/sqlalchemy/dialects/postgresql/pg8000.py +++ b/lib/sqlalchemy/dialects/postgresql/pg8000.py @@ -328,6 +328,13 @@ class PGDialect_pg8000(PGDialect): return ([], opts) def is_disconnect(self, e, connection, cursor): + if isinstance( + e, self.dbapi.InterfaceError + ) and "network error" in str(e): + # new as of pg8000 1.19.0 for broken connections + return True + + # connection was closed normally return "connection is closed" in str(e) def set_isolation_level(self, connection, level):