summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-05-30 11:53:46 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2014-05-30 11:53:46 -0400
commit4eb855657a31909f2c39410e589936b1b451709d (patch)
treebe96653595bc60e7ff2ed7c513937756377bfe12
parentf26669ae1b066052c6d8a251d82d2b7cb96f8c41 (diff)
parent7ee8cd8f5ea609a8bef1153fdf85c15a2b5abcc3 (diff)
downloadsqlalchemy-4eb855657a31909f2c39410e589936b1b451709d.tar.gz
Merge branch 'psycopg_disconnect' of https://github.com/dirkmueller/sqlalchemy
-rw-r--r--lib/sqlalchemy/dialects/postgresql/psycopg2.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/psycopg2.py b/lib/sqlalchemy/dialects/postgresql/psycopg2.py
index 233731b5d..b79dfdb2a 100644
--- a/lib/sqlalchemy/dialects/postgresql/psycopg2.py
+++ b/lib/sqlalchemy/dialects/postgresql/psycopg2.py
@@ -489,12 +489,16 @@ class PGDialect_psycopg2(PGDialect):
def is_disconnect(self, e, connection, cursor):
if isinstance(e, self.dbapi.Error):
+ # Is the connection already marked as closed?
+ if getattr(connection, 'closed', False):
+ return True
+
str_e = str(e).partition("\n")[0]
for msg in [
# these error messages from libpq: interfaces/libpq/fe-misc.c
# and interfaces/libpq/fe-secure.c.
# TODO: these are sent through gettext in libpq and we can't
- # check within other locales - consider using connection.closed
+ # check within other locales
'terminating connection',
'closed the connection',
'connection not open',