from__future__importannotations# For type hinting before definition, ref: https://stackoverflow.com/questions/33533148/how-do-i-specify-that-the-return-type-of-a-method-is-the-same-as-the-class-itsel
importsys
importtraceback
# Require Python 3
ifsys.version_info[0]<3:
raiseException("Must be using Python 3")
...
...
@@ -24,11 +25,13 @@ import copy
importthreading
importrandom
importtime
importlogging
importdatetime
importtextwrap
fromtypingimportList
fromtypingimportDict
fromutil.logimport*
fromutil.dnodesimport*
...
...
@@ -45,6 +48,14 @@ logger = None
defrunThread(wt:WorkerThread):
wt.run()
classCrashGenError(Exception):
def__init__(self,msg=None,errno=None):
self.msg=msg
self.errno=errno
def__str__(self):
returnself.msg
classWorkerThread:
def__init__(self,pool:ThreadPool,tid,
tc:ThreadCoordinator,
...
...
@@ -63,10 +74,10 @@ class WorkerThread:
self._dbConn=DbConn()
deflogDebug(self,msg):
logger.info(" t[{}] {}".format(self._tid,msg))
logger.debug(" TRD[{}] {}".format(self._tid,msg))
deflogInfo(self,msg):
logger.info(" t[{}] {}".format(self._tid,msg))
logger.info(" TRD[{}] {}".format(self._tid,msg))
defgetTaskExecutor(self):
...
...
@@ -95,15 +106,19 @@ class WorkerThread:
whileTrue:
tc=self._tc# Thread Coordinator, the overall master
tc.crossStepBarrier()# shared barrier first, INCLUDING the last one