[Zodb-checkins] CVS: ZODB3/ZODB/tests - PackableStorage.py:1.23

Tim Peters tim.one at comcast.net
Sat Oct 4 23:04:00 EDT 2003


Update of /cvs-repository/ZODB3/ZODB/tests
In directory cvs.zope.org:/tmp/cvs-serv12182/ZODB/tests

Modified Files:
	PackableStorage.py 
Log Message:
_PackWhileWriting() and class ClientThread:  Dumping in some prints showed
that the first thread to launch managed to commit each time, while the
other 3 threads got nothing but conflict errors.  Added some randomization
to boost the odds of success, and to prevent systematic favoring of any
thread.  That appears to work.


=== ZODB3/ZODB/tests/PackableStorage.py 1.22 => 1.23 ===
--- ZODB3/ZODB/tests/PackableStorage.py:1.22	Thu Oct  2 14:17:17 2003
+++ ZODB3/ZODB/tests/PackableStorage.py	Sat Oct  4 23:03:58 2003
@@ -398,12 +398,13 @@
         snooze()
         packt = time.time()
 
-        for j in range(10):
-            for i in range(10):
+        choices = range(10)
+        for dummy in choices:
+            for i in choices:
                 root[i].value = MinPO(i)
                 get_transaction().commit()
 
-        threads = [ClientThread(db) for i in range(4)]
+        threads = [ClientThread(db, choices) for i in range(4)]
         for t in threads:
             t.start()
 
@@ -504,16 +505,20 @@
         for r in self._storage.undoLog(): print r
         # what can we assert about that?
 
+
 class ClientThread(threading.Thread):
 
-    def __init__(self, db):
+    def __init__(self, db, choices):
         threading.Thread.__init__(self)
         self.root = db.open().root()
+        self.choices = choices
 
     def run(self):
+        from random import choice
+
         for j in range(50):
             try:
-                self.root[j % 10].value = MinPO(j)
+                self.root[choice(self.choices)].value = MinPO(j)
                 get_transaction().commit()
             except ConflictError:
                 get_transaction().abort()




More information about the Zodb-checkins mailing list