Commit f41ed0b5 authored by Chris McDonough's avatar Chris McDonough

Less verbose output.

parent b63a4b46
...@@ -37,7 +37,9 @@ from cPickle import UnpickleableError ...@@ -37,7 +37,9 @@ from cPickle import UnpickleableError
from ZODB.DemoStorage import DemoStorage from ZODB.DemoStorage import DemoStorage
from tempstorage.TemporaryStorage import TemporaryStorage from tempstorage.TemporaryStorage import TemporaryStorage
from OFS.Application import Application from OFS.Application import Application
from OFS.Folder import Folder
import sys import sys
import traceback
from zLOG import log_time from zLOG import log_time
sys.setcheckinterval(200) sys.setcheckinterval(200)
...@@ -77,7 +79,7 @@ class Foo(Acquisition.Implicit): pass ...@@ -77,7 +79,7 @@ class Foo(Acquisition.Implicit): pass
def _populate(app): def _populate(app):
bidmgr = BrowserIdManager(idmgr_name) bidmgr = BrowserIdManager(idmgr_name)
tf = MountedTemporaryFolder(tf_name, title="Temporary Folder") tf = MountedTemporaryFolder(tf_name, 'Temporary Folder')
toc = TransientObjectContainer(toc_name, title='Temporary ' toc = TransientObjectContainer(toc_name, title='Temporary '
'Transient Object Container', timeout_mins=1) 'Transient Object Container', timeout_mins=1)
session_data_manager=SessionDataManager(id=sdm_name, session_data_manager=SessionDataManager(id=sdm_name,
...@@ -114,12 +116,12 @@ class TestMultiThread(TestCase): ...@@ -114,12 +116,12 @@ class TestMultiThread(TestCase):
def go(self, token): def go(self, token):
readers = [] readers = []
writers = [] writers = []
readiters = 100 readiters = 3
writeiters = 100 writeiters = 3
readout = [] readout = []
writeout = [] writeout = []
numreaders = 4 numreaders = 2
numwriters = 2 numwriters = 4
numvaluers = 1 numvaluers = 1
db = _getDB() db = _getDB()
for i in range(numreaders): for i in range(numreaders):
...@@ -137,11 +139,11 @@ class TestMultiThread(TestCase): ...@@ -137,11 +139,11 @@ class TestMultiThread(TestCase):
for thread in writers: for thread in writers:
thread.start() thread.start()
time.sleep(0.1) time.sleep(0.1)
active = 2 active = threading.activeCount()
while active > 1: while active > 1:
active = threading.activeCount() active = threading.activeCount()
print 'waiting for %s threads' % active print 'waiting for %s threads' % active
time.sleep(1) time.sleep(5)
class BaseReaderWriter(threading.Thread): class BaseReaderWriter(threading.Thread):
def __init__(self, db, iters, token=None): def __init__(self, db, iters, token=None):
...@@ -153,7 +155,6 @@ class BaseReaderWriter(threading.Thread): ...@@ -153,7 +155,6 @@ class BaseReaderWriter(threading.Thread):
self.app.REQUEST.browser_id_ = token self.app.REQUEST.browser_id_ = token
self.iters = iters self.iters = iters
self.sdm_name = sdm_name self.sdm_name = sdm_name
self.out = []
threading.Thread.__init__(self) threading.Thread.__init__(self)
def run(self): def run(self):
...@@ -164,22 +165,25 @@ class BaseReaderWriter(threading.Thread): ...@@ -164,22 +165,25 @@ class BaseReaderWriter(threading.Thread):
self.run1() self.run1()
return return
except ReadConflictError: except ReadConflictError:
print "read conflict" print "R",
except BTreesConflictError: except BTreesConflictError:
print "btrees conflict" print "B",
except ConflictError: except ConflictError:
print "general conflict" print "W",
except: except:
get_transaction().abort() get_transaction().abort()
print log_time() print log_time()
traceback.print_exc()
raise raise
i = i + 1 i = i + 1
get_transaction().abort() get_transaction().abort()
self.conn.sync()
time.sleep(random.randrange(5) * .1) time.sleep(random.randrange(5) * .1)
finally: finally:
self.conn.close() self.conn.close()
del self.app del self.app
print i print '%s finished' % self.__class__
class ReaderThread(BaseReaderWriter): class ReaderThread(BaseReaderWriter):
def run1(self): def run1(self):
...@@ -190,8 +194,6 @@ class ReaderThread(BaseReaderWriter): ...@@ -190,8 +194,6 @@ class ReaderThread(BaseReaderWriter):
get_transaction().commit() get_transaction().commit()
for i in range(self.iters): for i in range(self.iters):
data = session_data_manager.getSessionData() data = session_data_manager.getSessionData()
if not data.has_key(t):
self.out.append(1)
time.sleep(random.choice(range(3))) time.sleep(random.choice(range(3)))
get_transaction().commit() get_transaction().commit()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment