Commit 12c1628e authored by Kirill Smelkov's avatar Kirill Smelkov

racetest: Adjust function comments to be more clear when they refer to function name

As suggested by @d-maurer:

https://github.com/zopefoundation/ZODB/pull/368#issuecomment-1233198328
https://github.com/zopefoundation/ZODB/pull/368#issuecomment-1233245299
parent 6f5703c8
...@@ -144,11 +144,12 @@ class RaceTests(object): ...@@ -144,11 +144,12 @@ class RaceTests(object):
assert IModelSpec.providedBy(spec) assert IModelSpec.providedBy(spec)
db = DB(self._storage) db = DB(self._storage)
# init initializes the database according to the spec. # `init` initializes the database according to the spec.
def init(): def init():
_state_init(db, spec) _state_init(db, spec)
# verify accesses objects in the database and verifies spec invariant. # `verify` accesses objects in the database and verifies spec
# invariant.
# #
# Access to half of the objects is organized to always trigger loading # Access to half of the objects is organized to always trigger loading
# from zstor. Access to the other half goes through zconn cache and so # from zstor. Access to the other half goes through zconn cache and so
...@@ -177,7 +178,7 @@ class RaceTests(object): ...@@ -177,7 +178,7 @@ class RaceTests(object):
transaction.abort() transaction.abort()
zconn.close() zconn.close()
# modify changes objects in the database by executing "next" step. # `modify` changes objects in the database by executing "next" step.
# #
# Spec invariant should be preserved. # Spec invariant should be preserved.
def modify(): def modify():
...@@ -191,7 +192,7 @@ class RaceTests(object): ...@@ -191,7 +192,7 @@ class RaceTests(object):
transaction.commit() transaction.commit()
zconn.close() zconn.close()
# xrun runs f in a loop until either N iterations, or until failed is # `xrun` runs f in a loop until either N iterations, or until failed is
# set. # set.
def xrun(f, N): def xrun(f, N):
try: try:
...@@ -230,7 +231,7 @@ class RaceTests(object): ...@@ -230,7 +231,7 @@ class RaceTests(object):
def _new_storage_client(self): def _new_storage_client(self):
raise NotImplementedError raise NotImplementedError
# dbopen creates new client storage connection and wraps it with DB. # `dbopen` creates new client storage connection and wraps it with DB.
def dbopen(self): def dbopen(self):
try: try:
zstor = self._new_storage_client() zstor = self._new_storage_client()
...@@ -255,7 +256,7 @@ class RaceTests(object): ...@@ -255,7 +256,7 @@ class RaceTests(object):
def _check_race_load_vs_external_invalidate(self, spec): def _check_race_load_vs_external_invalidate(self, spec):
assert IModelSpec.providedBy(spec) assert IModelSpec.providedBy(spec)
# init initializes the database according to the spec. # `init` initializes the database according to the spec.
def init(): def init():
db = self.dbopen() db = self.dbopen()
_state_init(db, spec) _state_init(db, spec)
...@@ -270,7 +271,7 @@ class RaceTests(object): ...@@ -270,7 +271,7 @@ class RaceTests(object):
# nwork=4. # nwork=4.
nwork = 8 nwork = 8
# T is a worker that accesses database in a loop and verifies # `T` is a worker that accesses database in a loop and verifies
# spec invariant. # spec invariant.
# #
# Access to half of the objects is organized to always trigger loading # Access to half of the objects is organized to always trigger loading
...@@ -365,7 +366,7 @@ class RaceTests(object): ...@@ -365,7 +366,7 @@ class RaceTests(object):
def _check_race_external_invalidate_vs_disconnect(self, spec): def _check_race_external_invalidate_vs_disconnect(self, spec):
assert IModelSpec.providedBy(spec) assert IModelSpec.providedBy(spec)
# init initializes the database according to the spec. # `init` initializes the database according to the spec.
def init(): def init():
db = self.dbopen() db = self.dbopen()
_state_init(db, spec) _state_init(db, spec)
...@@ -373,7 +374,7 @@ class RaceTests(object): ...@@ -373,7 +374,7 @@ class RaceTests(object):
nwork = 8*8 # nwork^2 from _check_race_load_vs_external_invalidate nwork = 8*8 # nwork^2 from _check_race_load_vs_external_invalidate
# T is similar to the T from _check_race_load_vs_external_invalidate # `T` is similar to the T from _check_race_load_vs_external_invalidate
# but reconnects to the database often. # but reconnects to the database often.
failed = threading.Event() failed = threading.Event()
failure = [None] * nwork # [tx] is failure from T(tx) failure = [None] * nwork # [tx] is failure from T(tx)
...@@ -451,7 +452,7 @@ class RaceTests(object): ...@@ -451,7 +452,7 @@ class RaceTests(object):
self.fail('\n\n'.join([_ for _ in failure if _])) self.fail('\n\n'.join([_ for _ in failure if _]))
# _state_init initializes the database according to the spec. # `_state_init` initializes the database according to the spec.
def _state_init(db, spec): def _state_init(db, spec):
transaction.begin() transaction.begin()
zconn = db.open() zconn = db.open()
...@@ -462,8 +463,8 @@ def _state_init(db, spec): ...@@ -462,8 +463,8 @@ def _state_init(db, spec):
zconn.close() zconn.close()
# _state_invalidate_half1 invalidatates first 50% of database objects, so that # `_state_invalidate_half1` invalidatates first 50% of database objects, so
# the next time they are accessed, they are reloaded from the storage. # that the next time they are accessed, they are reloaded from the storage.
def _state_invalidate_half1(root): def _state_invalidate_half1(root):
keys = list(sorted(root.keys())) keys = list(sorted(root.keys()))
for k in keys[:len(keys)//2]: for k in keys[:len(keys)//2]:
...@@ -471,8 +472,8 @@ def _state_invalidate_half1(root): ...@@ -471,8 +472,8 @@ def _state_invalidate_half1(root):
obj._p_invalidate() obj._p_invalidate()
# _state_details returns text details about ZODB objects directly referenced by # `_state_details` returns text details about ZODB objects directly referenced
# root. # by root.
def _state_details(root): # -> txt def _state_details(root): # -> txt
# serial for all objects # serial for all objects
keys = list(sorted(root.keys())) keys = list(sorted(root.keys()))
......
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