[Zodb-checkins] CVS: ZODB/src/ZEO/tests - stress.py:1.11
speed.py:1.13 multi.py:1.13 deadlock.py:1.2
InvalidationTests.py:1.13
Jeremy Hylton
jeremy at zope.com
Fri Apr 16 11:58:45 EDT 2004
Update of /cvs-repository/ZODB/src/ZEO/tests
In directory cvs.zope.org:/tmp/cvs-serv11088/src/ZEO/tests
Modified Files:
stress.py speed.py multi.py deadlock.py InvalidationTests.py
Log Message:
Replace use of builtin get_transaction() with explicit transaction module.
=== ZODB/src/ZEO/tests/stress.py 1.10 => 1.11 ===
--- ZODB/src/ZEO/tests/stress.py:1.10 Thu Feb 26 19:31:52 2004
+++ ZODB/src/ZEO/tests/stress.py Fri Apr 16 11:58:13 2004
@@ -18,11 +18,12 @@
"""
# XXX This code is currently broken.
+import transaction
import ZODB
-from ZEO.ClientStorage import ClientStorage
from ZODB.MappingStorage import MappingStorage
-from ZEO.tests import forker
from ZODB.tests import MinPO
+from ZEO.ClientStorage import ClientStorage
+from ZEO.tests import forker
import os
import random
@@ -59,7 +60,7 @@
o = MinPO.MinPO(prev)
prev = o
root[an_object()] = o
- get_transaction().commit()
+ transaction.commit()
cn.close()
def work(cn):
@@ -71,7 +72,7 @@
while not isinstance(obj.value, types.StringType):
obj = obj.value
obj.value = an_object()
- get_transaction().commit()
+ transaction.commit()
def main():
# Yuck! Need to cleanup forker so that the API is consistent
=== ZODB/src/ZEO/tests/speed.py 1.12 => 1.13 ===
--- ZODB/src/ZEO/tests/speed.py:1.12 Wed Mar 3 09:31:39 2004
+++ ZODB/src/ZEO/tests/speed.py Fri Apr 16 11:58:13 2004
@@ -45,10 +45,11 @@
import sys, os, getopt, time
##sys.path.insert(0, os.getcwd())
-import ZODB
import persistent
-from ZEO.tests import forker
+import transaction
+import ZODB
from ZODB.POSException import ConflictError
+from ZEO.tests import forker
class P(persistent.Persistent):
pass
@@ -84,7 +85,7 @@
jar = db.open()
while 1:
try:
- get_transaction().begin()
+ transaction.begin()
rt = jar.root()
key = 's%s' % r
if rt.has_key(key):
@@ -98,7 +99,7 @@
else:
v.d = data
setattr(p, str(i), v)
- get_transaction().commit()
+ transaction.commit()
except ConflictError:
conflicts = conflicts + 1
else:
=== ZODB/src/ZEO/tests/multi.py 1.12 => 1.13 ===
--- ZODB/src/ZEO/tests/multi.py:1.12 Thu Feb 26 19:31:52 2004
+++ ZODB/src/ZEO/tests/multi.py Fri Apr 16 11:58:13 2004
@@ -17,6 +17,7 @@
import ZODB, ZODB.DB, ZODB.FileStorage, ZODB.POSException
import persistent
import persistent.mapping
+import transaction
from ZEO.tests import forker
import os
@@ -57,7 +58,7 @@
db = ZODB.DB(fs)
root = db.open().root()
root["multi"] = persistent.mapping.PersistentMapping()
- get_transaction().commit()
+ transaction.commit()
return fs
@@ -95,9 +96,9 @@
while 1:
try:
s = root[pid] = Stats()
- get_transaction().commit()
+ transaction.commit()
except ZODB.POSException.ConflictError:
- get_transaction().abort()
+ transaction.abort()
time.sleep(CONFLICT_DELAY)
else:
break
@@ -111,16 +112,16 @@
r = dict[size] = Record(pid, size)
if prev:
prev.set_next(r)
- get_transaction().commit()
+ transaction.commit()
except ZODB.POSException.ConflictError, err:
- get_transaction().abort()
+ transaction.abort()
time.sleep(CONFLICT_DELAY)
else:
i = i + 1
if VERBOSE and (i < 5 or i % 10 == 0):
print "Client %s: %s of %s" % (pid, i, RECORDS_PER_CLIENT)
s.done()
- get_transaction().commit()
+ transaction.commit()
print "Client completed:", pid
=== ZODB/src/ZEO/tests/deadlock.py 1.1 => 1.2 ===
--- ZODB/src/ZEO/tests/deadlock.py:1.1 Wed Oct 30 16:15:07 2002
+++ ZODB/src/ZEO/tests/deadlock.py Fri Apr 16 11:58:13 2004
@@ -25,7 +25,7 @@
update(r1, r2)
except ConflictError, msg:
print msg
- get_transaction().abort()
+ transaction.abort()
c1.sync()
c2.sync()
except (ClientDisconnected, DisconnectedError), err:
@@ -41,7 +41,7 @@
random.shuffle(updates)
for key, root in updates:
root[key] = time.time()
- get_transaction().commit()
+ transaction.commit()
print os.getpid(), k1, k2
if __name__ == "__main__":
=== ZODB/src/ZEO/tests/InvalidationTests.py 1.12 => 1.13 ===
--- ZODB/src/ZEO/tests/InvalidationTests.py:1.12 Thu Apr 15 12:31:00 2004
+++ ZODB/src/ZEO/tests/InvalidationTests.py Fri Apr 16 11:58:13 2004
@@ -39,7 +39,7 @@
# of obscure timing-related bugs in cache consistency logic, revealed
# by failure of the BTree to pass internal consistency checks at the end,
# and/or by failure of the BTree to contain all the keys the threads
-# thought they added (i.e., the keys for which get_transaction().commit()
+# thought they added (i.e., the keys for which transaction.commit()
# did not raise any exception).
class FailableThread(TestThread):
@@ -151,19 +151,19 @@
tree = cn.root()["tree"]
break
except (ConflictError, KeyError):
- get_transaction().abort()
+ transaction.abort()
cn.sync()
key = self.startnum
while not self.stop.isSet():
try:
tree[key] = self.threadnum
- get_transaction().note("add key %s" % key)
- get_transaction().commit()
+ transaction.get().note("add key %s" % key)
+ transaction.commit()
self.commitdict[self] = 1
if self.sleep:
time.sleep(self.sleep)
except (ReadConflictError, ConflictError), msg:
- get_transaction().abort()
+ transaction.abort()
# sync() is necessary here to process invalidations
# if we get a read conflict. In the read conflict case,
# no objects were modified so cn never got registered
@@ -209,7 +209,7 @@
break
except (ConflictError, KeyError):
# print "%d getting tree abort" % self.threadnum
- get_transaction().abort()
+ transaction.abort()
cn.sync()
keys_added = {} # set of keys we commit
@@ -231,20 +231,20 @@
tree[key] = self.threadnum
except (ReadConflictError, ConflictError), msg:
# print "%d setting key %s" % (self.threadnum, msg)
- get_transaction().abort()
+ transaction.abort()
cn.sync()
break
else:
# print "%d set #%d" % (self.threadnum, len(keys))
- get_transaction().note("keys %s" % ", ".join(map(str, keys)))
+ transaction.get().note("keys %s" % ", ".join(map(str, keys)))
try:
- get_transaction().commit()
+ transaction.commit()
self.commitdict[self] = 1
if self.sleep:
time.sleep(self.sleep)
except ConflictError, msg:
# print "%d commit %s" % (self.threadnum, msg)
- get_transaction().abort()
+ transaction.abort()
cn.sync()
continue
for k in keys:
@@ -304,17 +304,17 @@
tree = cn.root()["tree"]
break
except (ConflictError, KeyError):
- get_transaction().abort()
+ transaction.abort()
cn.sync()
while not self.stop.isSet():
try:
tree[key] = self.threadnum
- get_transaction().commit()
+ transaction.commit()
if self.sleep:
time.sleep(self.sleep)
break
except (VersionLockError, ReadConflictError, ConflictError), msg:
- get_transaction().abort()
+ transaction.abort()
# sync() is necessary here to process invalidations
# if we get a read conflict. In the read conflict case,
# no objects were modified so cn never got registered
@@ -327,16 +327,16 @@
try:
if commit:
self.db.commitVersion(version)
- get_transaction().note("commit version %s" % version)
+ transaction.get().note("commit version %s" % version)
else:
self.db.abortVersion(version)
- get_transaction().note("abort version %s" % version)
- get_transaction().commit()
+ transaction.get().note("abort version %s" % version)
+ transaction.commit()
if self.sleep:
time.sleep(self.sleep)
return commit
except ConflictError, msg:
- get_transaction().abort()
+ transaction.abort()
cn.sync()
finally:
cn.close()
@@ -368,7 +368,7 @@
tree._check()
except ReadConflictError:
if retries:
- get_transaction().abort()
+ transaction.abort()
cn.sync()
else:
raise
@@ -427,7 +427,7 @@
cn = db1.open()
tree = cn.root()["tree"] = OOBTree()
- get_transaction().commit()
+ transaction.commit()
# DM: allow time for invalidations to come in and process them
time.sleep(0.1)
@@ -453,7 +453,7 @@
cn = db1.open()
tree = cn.root()["tree"] = OOBTree()
- get_transaction().commit()
+ transaction.commit()
cn.close()
# Run two threads that update the BTree
@@ -482,7 +482,7 @@
cn = db1.open()
tree = cn.root()["tree"] = OOBTree()
- get_transaction().commit()
+ transaction.commit()
cn.close()
# Run two threads that update the BTree
@@ -507,7 +507,7 @@
cn = db1.open()
tree = cn.root()["tree"] = OOBTree()
- get_transaction().commit()
+ transaction.commit()
cn.close()
# Run three threads that update the BTree.
@@ -543,7 +543,7 @@
cn = db1.open()
tree = cn.root()["tree"] = OOBTree()
- get_transaction().commit()
+ transaction.commit()
cn.close()
# Run three threads that update the BTree.
@@ -582,7 +582,7 @@
tree = cn.root()["tree"] = OOBTree()
for i in range(0, 3000, 2):
tree[i] = 0
- get_transaction().commit()
+ transaction.commit()
cn.close()
# Run three threads that update the BTree.
@@ -608,7 +608,7 @@
losers = [k for k, v in tree.items() if v == 0]
for k in losers:
del tree[k]
- get_transaction().commit()
+ transaction.commit()
self._check_threads(tree, t1, t2, t3)
More information about the Zodb-checkins
mailing list