Commit fb4db937 authored by Jeremy Hylton's avatar Jeremy Hylton

Attempt to be more robust about unstoppable worker threads.

Mark each WorkerThread as a daemon.  Attempt to join() it when the
test exits, but do so with a timeout.  If, after the join(), the
thread is still alive, mark the test as failed.  Since it's just a
daemon thread, the test program should still exit.
parent 9046ef9f
...@@ -37,14 +37,17 @@ class WorkerThread(threading.Thread): ...@@ -37,14 +37,17 @@ class WorkerThread(threading.Thread):
self.trans = trans self.trans = trans
self.method = method self.method = method
threading.Thread.__init__(self) threading.Thread.__init__(self)
self.setDaemon(True)
def run(self): def run(self):
try: try:
self.storage.tpc_begin(self.trans) self.storage.tpc_begin(self.trans)
oid = self.storage.new_oid() oid = self.storage.new_oid()
self.storage.store(oid, ZERO, zodb_pickle(MinPO("c")), '', self.trans) p = zodb_pickle(MinPO("c"))
self.storage.store(oid, ZERO, p, '', self.trans)
oid = self.storage.new_oid() oid = self.storage.new_oid()
self.storage.store(oid, ZERO, zodb_pickle(MinPO("c")), '', self.trans) p = zodb_pickle(MinPO("c"))
self.storage.store(oid, ZERO, p, '', self.trans)
self.storage.tpc_vote(self.trans) self.storage.tpc_vote(self.trans)
if self.method == "tpc_finish": if self.method == "tpc_finish":
self.storage.tpc_finish(self.trans) self.storage.tpc_finish(self.trans)
...@@ -154,7 +157,9 @@ class CommitLockTests: ...@@ -154,7 +157,9 @@ class CommitLockTests:
def _dowork2(self, method_name): def _dowork2(self, method_name):
for t in self._threads: for t in self._threads:
t.join() t.join(10)
for t in self._threads:
self.failIf(t.isAlive())
def _duplicate_client(self): def _duplicate_client(self):
"Open another ClientStorage to the same server." "Open another ClientStorage to the same server."
......
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