changeset 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 10785c0fd48f
children 2d080ca7f8bd
files MoinMoin/caching.py MoinMoin/util/filesys.py
diffstat 2 files changed, 9 insertions(+), 6 deletions(-) [+]
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)
--- a/MoinMoin/util/filesys.py	Thu Sep 10 09:20:25 2009 +0200
+++ b/MoinMoin/util/filesys.py	Thu Sep 10 11:57:44 2009 +0100
@@ -142,7 +142,7 @@
     """
     if sys.platform == 'win32':
         def wrapper(*args, **kwargs):
-            max_retries = 10
+            max_retries = 42
             retry = 0
             while True:
                 try: