diff options
author | hbusul <h.burak.usul@gmail.com> | 2021-03-29 11:42:33 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-03-30 11:02:40 -0400 |
commit | 42f29ae6525a5c5348c3ff2926607ec53eed5190 (patch) | |
tree | cb1a68e85dfb6ce5249a253517e2ed9b99ac2ffb /lib/sqlalchemy/dialects/postgresql/pg8000.py | |
parent | 2c2e01a0c6d0847f5648fd0120c8fa0bd5f6268f (diff) | |
download | sqlalchemy-42f29ae6525a5c5348c3ff2926607ec53eed5190.tar.gz |
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
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql/pg8000.py')
-rw-r--r-- | lib/sqlalchemy/dialects/postgresql/pg8000.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/pg8000.py b/lib/sqlalchemy/dialects/postgresql/pg8000.py index 6e7318272..cda0bc941 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): |