]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Added an additional libpq message to the list of "disconnect"
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 9 Feb 2011 15:58:16 +0000 (10:58 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 9 Feb 2011 15:58:16 +0000 (10:58 -0500)
exceptions, "could not receive data from server"
[ticket:2044]

CHANGES
lib/sqlalchemy/dialects/postgresql/psycopg2.py

diff --git a/CHANGES b/CHANGES
index de02aedf11f9394e3a26aac0092a02fd0afc46e1..25c6aa08cd66946133a6b60837592aa0687e382c 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -37,6 +37,10 @@ CHANGES
     than 63 characters using the same logic Postgresql uses.  
     [ticket:1083]
 
+  - Added an additional libpq message to the list of "disconnect"
+    exceptions, "could not receive data from server"
+    [ticket:2044]
+
 0.6.6
 =====
 - orm
index eb068bc56ef8a01d0324e699813d7ab7b7c80f49..a0b356c62a426ade01f0d539a147373b0dca5da2 100644 (file)
@@ -282,11 +282,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