From 71292e82585973cec2f139ed7d0cb9b53962d496 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Tue, 25 Sep 2012 16:54:50 -0400 Subject: [PATCH] - [bug] Added 'terminating connection' to the list of messages we use to detect a disconnect with PG, which appears to be present in some versions when the server is restarted. [ticket:2570] --- CHANGES | 5 +++++ lib/sqlalchemy/dialects/postgresql/psycopg2.py | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 2dab1c0189..289876b074 100644 --- a/CHANGES +++ b/CHANGES @@ -172,6 +172,11 @@ CHANGES orders them. Courtesy Gunnlaugur Þór Briem. [ticket:2531]. + - [bug] Added 'terminating connection' to the list + of messages we use to detect a disconnect with PG, which + appears to be present in some versions when the server + is restarted. [ticket:2570] + - mysql - [bug] Updated mysqlconnector interface to use updated "client flag" and "charset" APIs, diff --git a/lib/sqlalchemy/dialects/postgresql/psycopg2.py b/lib/sqlalchemy/dialects/postgresql/psycopg2.py index f9f992d04b..7fc66b1746 100644 --- a/lib/sqlalchemy/dialects/postgresql/psycopg2.py +++ b/lib/sqlalchemy/dialects/postgresql/psycopg2.py @@ -372,7 +372,8 @@ class PGDialect_psycopg2(PGDialect): # these error messages from libpq: interfaces/libpq/fe-misc.c. # TODO: these are sent through gettext in libpq and we can't # check within other locales - consider using connection.closed - return 'closed the connection' in str(e) or \ + return 'terminating connection' in str(e) or \ + 'closed the connection' in str(e) or \ 'connection not open' in str(e) or \ 'could not receive data from server' in str(e) elif isinstance(e, self.dbapi.InterfaceError): -- 2.47.2