changeset 412:481c432b3d11

fix some error handlers, logging for caching lock failures imported from: moin--main--1.5--patch-416
author Thomas Waldmann <tw@waldmann-edv.de>
date Fri, 03 Feb 2006 20:12:31 +0000
parents 6e2114f8e942
children c85132ab35e3
files ChangeLog MoinMoin/caching.py MoinMoin/request.py
diffstat 3 files changed, 28 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Feb 03 19:53:23 2006 +0000
+++ b/ChangeLog	Fri Feb 03 20:12:31 2006 +0000
@@ -2,6 +2,20 @@
 # arch-tag: automatic-ChangeLog--arch@arch.thinkmo.de--2003-archives/moin--main--1.5
 #
 
+2006-02-03 21:12:31 GMT	Thomas Waldmann <tw@waldmann-edv.de>	patch-416
+
+    Summary:
+      fix some error handlers, logging for caching lock failures
+    Revision:
+      moin--main--1.5--patch-416
+
+    fix some error handlers, logging for caching lock failures
+    
+
+    modified files:
+     ChangeLog MoinMoin/caching.py MoinMoin/request.py
+
+
 2006-02-03 20:53:23 GMT	Thomas Waldmann <tw@waldmann-edv.de>	patch-415
 
     Summary:
--- a/MoinMoin/caching.py	Fri Feb 03 19:53:23 2006 +0000
+++ b/MoinMoin/caching.py	Fri Feb 03 20:12:31 2006 +0000
@@ -22,6 +22,7 @@
                           page local cache area
             @param key: under which key we access the cache content
         """
+        self.request = request
         if isinstance(arena, str):
             self.arena_dir = os.path.join(request.cfg.cache_dir, arena)
             filesys.makeDirs(self.arena_dir)
@@ -30,9 +31,9 @@
             self.arena_dir = arena.getPagePath('cache', check_create=1)
         self.key = key
         if locking:
-            lock_dir = os.path.join(self.arena_dir, '__lock__')
-            self.rlock = lock.ReadLock(lock_dir, 60.0)
-            self.wlock = lock.WriteLock(lock_dir, 60.0)
+            self.lock_dir = os.path.join(self.arena_dir, '__lock__')
+            self.rlock = lock.ReadLock(self.lock_dir, 60.0)
+            self.wlock = lock.WriteLock(self.lock_dir, 60.0)
         
     def _filename(self):
         return os.path.join(self.arena_dir, self.key)
@@ -47,7 +48,8 @@
             return 0
 
     def needsUpdate(self, filename, attachdir=None):
-        if not self.exists(): return 1
+        if not self.exists():
+            return 1
 
         try:
             ctime = os.path.getmtime(self._filename())
@@ -79,6 +81,8 @@
             finally:
                 if locking:
                     self.wlock.release()
+        else:
+            request.log("Can't acquire write lock in %s", self.lock_dir)
 
     def update(self, content, encode=False):
         if encode:
@@ -95,6 +99,8 @@
             finally:
                 if locking:
                     self.wlock.release()
+        else:
+            request.log("Can't acquire write lock in %s", self.lock_dir)
 
     def remove(self):
         try:
@@ -111,6 +117,8 @@
             finally:
                 if locking:
                     self.rlock.release()
+        else:
+            request.log("Can't acquire read lock in %s", self.lock_dir)
         if decode:
             data = data.decode(config.charset)
         return data
--- a/MoinMoin/request.py	Fri Feb 03 19:53:23 2006 +0000
+++ b/MoinMoin/request.py	Fri Feb 03 20:12:31 2006 +0000
@@ -194,7 +194,7 @@
                         events = surgedict.setdefault(id, copy.copy({}))
                         timestamps = events.setdefault(action, copy.copy([]))
                         timestamps.append((t, surge_indicator))
-                except:
+                except StandardError, err:
                     pass
         
             maxnum, dt = limits.get(current_action, default_limit)
@@ -214,7 +214,7 @@
                         data.append("%s\t%d\t%s\t%s" % (id, t, action, surge_indicator))
             data = "\n".join(data)
             cache.update(data)
-        except:
+        except StandardError, err:
             pass
 
         return surge_detected