Commit 90f912c9 authored by Dieter Maurer's avatar Dieter Maurer Committed by GitHub

Merge pull request #376 from zopefoundation/fix_racetests

Fix `racetest` problems
parents 9ffc59e5 618a79c1
...@@ -5,6 +5,9 @@ ...@@ -5,6 +5,9 @@
5.8.1 (unreleased) 5.8.1 (unreleased)
================== ==================
- Fix ``racetest`` problems.
For details see `#376 <https://github.com/zopefoundation/ZODB/pull/376>`_.
5.8.0 (2022-11-09) 5.8.0 (2022-11-09)
================== ==================
......
...@@ -227,7 +227,7 @@ def VmSize(): ...@@ -227,7 +227,7 @@ def VmSize():
except: # noqa: E722 do not use bare 'except' except: # noqa: E722 do not use bare 'except'
return 0 return 0
else: else:
l_ = list(filter(lambda l: l[:7] == 'VmSize:', lines)) l_ = list(filter(lambda l: l[:7] == 'VmSize:', lines)) # noqa: E741
if l_: if l_:
l_ = l_[0][7:].strip().split()[0] l_ = l_[0][7:].strip().split()[0]
return int(l_) return int(l_)
......
...@@ -214,9 +214,9 @@ class RaceTests(object): ...@@ -214,9 +214,9 @@ class RaceTests(object):
init() init()
N = 500 N = 500
tverify = threading.Thread( tverify = Daemon(
name='Tverify', target=xrun, args=(verify, N)) name='Tverify', target=xrun, args=(verify, N))
tmodify = threading.Thread( tmodify = Daemon(
name='Tmodify', target=xrun, args=(modify, N)) name='Tmodify', target=xrun, args=(modify, N))
tverify.start() tverify.start()
tmodify.start() tmodify.start()
...@@ -340,7 +340,7 @@ class RaceTests(object): ...@@ -340,7 +340,7 @@ class RaceTests(object):
N = 100 N = 100
tg = [] tg = []
for x in range(nwork): for x in range(nwork):
t = threading.Thread(name='T%d' % x, target=T, args=(x, N)) t = Daemon(name='T%d' % x, target=T, args=(x, N))
t.start() t.start()
tg.append(t) tg.append(t)
...@@ -446,7 +446,7 @@ class RaceTests(object): ...@@ -446,7 +446,7 @@ class RaceTests(object):
N = 100 // (2*4) # N reduced to save time N = 100 // (2*4) # N reduced to save time
tg = [] tg = []
for x in range(nwork): for x in range(nwork):
t = threading.Thread(name='T%d' % x, target=T, args=(x, N)) t = Daemon(name='T%d' % x, target=T, args=(x, N))
t.start() t.start()
tg.append(t) tg.append(t)
...@@ -524,3 +524,15 @@ def _state_details(root): # -> txt ...@@ -524,3 +524,15 @@ def _state_details(root): # -> txt
txt += load(k) txt += load(k)
return txt return txt
class Daemon(threading.Thread):
"""auxiliary class to create daemon threads and fail if not stopped."""
def __init__(self, **kw):
super(Daemon, self).__init__(**kw)
self.daemon = True
def join(self, *args, **kw):
super(Daemon, self).join(*args, **kw)
if self.is_alive():
raise AssertionError("Thread %s did not stop" % self.name)
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