summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/postgresql/psycopg2.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2011-02-09 10:58:16 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2011-02-09 10:58:16 -0500
commitf473398f0170a00b0e760a7dba292087144c7e45 (patch)
tree04947975c987eb0e64b04970702d153c7c9f2b3b /lib/sqlalchemy/dialects/postgresql/psycopg2.py
parent8f381f202e569eda0d5de13f584304440492222c (diff)
downloadsqlalchemy-f473398f0170a00b0e760a7dba292087144c7e45.tar.gz
- Added an additional libpq message to the list of "disconnect"
exceptions, "could not receive data from server" [ticket:2044]
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql/psycopg2.py')
-rw-r--r--lib/sqlalchemy/dialects/postgresql/psycopg2.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/psycopg2.py b/lib/sqlalchemy/dialects/postgresql/psycopg2.py
index 21ce1211a..50ea9d437 100644
--- a/lib/sqlalchemy/dialects/postgresql/psycopg2.py
+++ b/lib/sqlalchemy/dialects/postgresql/psycopg2.py
@@ -297,11 +297,19 @@ class PGDialect_psycopg2(PGDialect):
def is_disconnect(self, e):
if isinstance(e, self.dbapi.OperationalError):
- return 'closed the connection' in str(e) or 'connection not open' in str(e)
+ # 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 \
+ 'connection not open' in str(e) or \
+ 'could not receive data from server' in str(e)
elif isinstance(e, self.dbapi.InterfaceError):
- return 'connection already closed' in str(e) or 'cursor already closed' in str(e)
+ # psycopg2 client errors, psycopg2/conenction.h, psycopg2/cursor.h
+ return 'connection already closed' in str(e) or \
+ 'cursor already closed' in str(e)
elif isinstance(e, self.dbapi.ProgrammingError):
- # yes, it really says "losed", not "closed"
+ # not sure where this path is originally from, it may
+ # be obsolete. It really says "losed", not "closed".
return "losed the connection unexpectedly" in str(e)
else:
return False