From: hbusul Date: Sun, 28 Mar 2021 17:49:36 +0000 (+0300) Subject: update pg8000 dialect is_disconnect method Fixes: #6099 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cd58836d3e19489d5203c02f7cc5f2f2d7c82a20;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git update pg8000 dialect is_disconnect method Fixes: #6099 --- diff --git a/lib/sqlalchemy/dialects/postgresql/pg8000.py b/lib/sqlalchemy/dialects/postgresql/pg8000.py index 6e73182727..33cf1bcbcf 100644 --- a/lib/sqlalchemy/dialects/postgresql/pg8000.py +++ b/lib/sqlalchemy/dialects/postgresql/pg8000.py @@ -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("_", " ")