]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
update pg8000 dialect is_disconnect method Fixes: #6099 6150/head
authorhbusul <h.burak.usul@gmail.com>
Sun, 28 Mar 2021 17:49:36 +0000 (20:49 +0300)
committerhbusul <h.burak.usul@gmail.com>
Sun, 28 Mar 2021 17:49:36 +0000 (20:49 +0300)
lib/sqlalchemy/dialects/postgresql/pg8000.py

index 6e7318272780a5b93478eba15fb389025efcfbb9..33cf1bcbcf38dc314ebf892e9e334a2deb35b77a 100644 (file)
@@ -328,7 +328,12 @@ class PGDialect_pg8000(PGDialect):
         return ([], opts)
 
     def is_disconnect(self, e, connection, cursor):
-        return "connection is closed" in str(e)
+        if isinstance(e, self.dbapi.InterfaceError):
+            # pg8000 returns InterfaceError with message set to
+            # "network error on read", "network error on write", or
+            # "network error on flush" in case of connection issues.
+            return str(e).startswith("network error")
+        return False
 
     def set_isolation_level(self, connection, level):
         level = level.replace("_", " ")