]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
accommodate new pg8000 disconnection exception
authorhbusul <h.burak.usul@gmail.com>
Mon, 29 Mar 2021 15:42:33 +0000 (11:42 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 30 Mar 2021 15:02:40 +0000 (11:02 -0400)
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

doc/build/changelog/unreleased_14/6099.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/postgresql/pg8000.py

diff --git a/doc/build/changelog/unreleased_14/6099.rst b/doc/build/changelog/unreleased_14/6099.rst
new file mode 100644 (file)
index 0000000..5e715b9
--- /dev/null
@@ -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.
+
index 6e7318272780a5b93478eba15fb389025efcfbb9..cda0bc9415ba63e511fa7e0e7b17fc749fda3f18 100644 (file)
@@ -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):