[Checkins] SVN: gocept.zeoraid/branches/distributed-remote-calls/src/gocept/zeoraid/storage.py Patch for distributing _apply_single_storage on a random storage

Dirceu Pereira Tiegs cvs-admin at zope.org
Fri Jun 13 06:58:17 EDT 2008


Log message for revision 87363:
  Patch for distributing _apply_single_storage on a random storage

Changed:
  U   gocept.zeoraid/branches/distributed-remote-calls/src/gocept/zeoraid/storage.py

-=-
Modified: gocept.zeoraid/branches/distributed-remote-calls/src/gocept/zeoraid/storage.py
===================================================================
--- gocept.zeoraid/branches/distributed-remote-calls/src/gocept/zeoraid/storage.py	2008-06-13 10:49:29 UTC (rev 87362)
+++ gocept.zeoraid/branches/distributed-remote-calls/src/gocept/zeoraid/storage.py	2008-06-13 10:58:17 UTC (rev 87363)
@@ -20,6 +20,7 @@
 import os
 import os.path
 import shutil
+import random
 
 import zope.interface
 
@@ -612,10 +613,16 @@
 
     @ensure_open_storage
     def _apply_single_storage(self, method_name, args=(), kw={}):
-        """Calls the given method on the first optimal storage."""
+        """Calls the given method on a random optimal storage."""
         # Try to find a storage that we can talk to. Stop after we found a
         # reliable result.
-        for name in self.storages_optimal[:]:
+        storages = self.storages_optimal[:]
+        reliable = False
+        while not reliable:
+            if not storages:
+                break
+            name = random.choice(storages)
+            storages.remove(name)
             reliable, result = self.__apply_storage(
                 name, method_name, args, kw)
             if reliable:



More information about the Checkins mailing list