[Python-checkins] r54913 - tracker/roundup-src/roundup/cgi/client.py

erik.forsberg python-checkins at python.org
Sat Apr 21 18:42:56 CEST 2007


Author: erik.forsberg
Date: Sat Apr 21 18:42:55 2007
New Revision: 54913

Modified:
   tracker/roundup-src/roundup/cgi/client.py
Log:
Try to cope with
http://sourceforge.net/tracker/index.php?func=detail&aid=1703116&group_id=31577&atid=402788
which is causing large amounts of mail from the tracker.


Modified: tracker/roundup-src/roundup/cgi/client.py
==============================================================================
--- tracker/roundup-src/roundup/cgi/client.py	(original)
+++ tracker/roundup-src/roundup/cgi/client.py	Sat Apr 21 18:42:55 2007
@@ -349,9 +349,28 @@
         if now - last_clean < hour:
             return
 
+        # This is a bit ugly, but right now, I'm too lazy to fix a new API
+        # in all rdbms-based backends to cope with this problem that only
+        # appears on Postgres.
+        try:
+            from psycopg import ProgrammingError
+        except ImportError:
+            from psycopg2.psycopg1 import ProgrammingError
+        except ImportError:
+            ProgrammingError = None
+
         sessions.clean(now)
         self.db.getOTKManager().clean(now)
-        sessions.set('last_clean', last_use=time.time())
+        try:
+            sessions.set('last_clean', last_use=time.time())
+        except ProgrammingError, err:
+            response = str(err).split('\n')[0]
+            if -1 != response.find('ERROR') and \
+               -1 != response.find('could not serialize access due to concurrent update'):
+                # Another client just updated, and we're running on
+                # serializable isolation.
+                # See http://www.postgresql.org/docs/7.4/interactive/transaction-iso.html
+                return 
         self.db.commit(fail_ok=True)
 
     def determine_charset(self):


More information about the Python-checkins mailing list