diff MoinMoin/caching.py @ 5142:294b97b991d3 1.8.5

work around windows caching lock problems (see details below) caching: fix wrong releasing of lock (if lock acquiring failed) caching: increase the timeout for trying to acquire a lock (1s -> 10s) filesys: increase retries for filesystem operations on win32 from 10 to 42 The underlying reason that makes these ugly workarounds in filesys necessary so it works on win32 is still unknown.
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Thu, 10 Sep 2009 11:57:44 +0100
parents 95a4aa0eb1e9
children 4c6a4adf0540
line wrap: on
line diff
--- a/MoinMoin/caching.py	Thu Sep 10 09:20:25 2009 +0200
+++ b/MoinMoin/caching.py	Thu Sep 10 11:57:44 2009 +0100
@@ -131,7 +131,7 @@
 
         return needsupdate
 
-    def lock(self, mode, timeout=1.0):
+    def lock(self, mode, timeout=10.0):
         """
         acquire a lock for <mode> ("r" or "w").
         we just raise a CacheError if this doesn't work.
@@ -143,11 +143,14 @@
         """
         lock_dir = os.path.join(self.arena_dir, '__lock__')
         if 'r' in mode:
-            self._lock = lock.LazyReadLock(lock_dir, 60.0)
+            _lock = lock.LazyReadLock(lock_dir, 60.0)
         elif 'w' in mode:
-            self._lock = lock.LazyWriteLock(lock_dir, 60.0)
-        acquired = self._lock.acquire(timeout)
-        if not acquired:
+            _lock = lock.LazyWriteLock(lock_dir, 60.0)
+        acquired = _lock.acquire(timeout)
+        if acquired:
+            self._lock = _lock
+        else:
+            self._lock = None
             err = "Can't acquire %s lock in %s" % (mode, lock_dir)
             logging.error(err)
             raise CacheError(err)