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
# Require Python 3
ifsys.version_info[0]<3:
raiseException("Must be using Python 3")
importgetopt
importargparse
...
...
@@ -25,57 +31,37 @@ from util.dnodes import *
fromutil.casesimport*
fromutil.sqlimport*
importcrash_gen
importtaos
# Global variables, tried to keep a small number.
gConfig=None# Command-line/Environment Configurations, will set a bit later
logger=None
# Command-line/Environment Configurations
gConfig=None# will set a bit later
defrunThread(workerThread):
workerThread.run()
# Used by one process to block till another is ready
# class Baton:
# def __init__(self):
# self._lock = threading.Lock() # control access to object
# self._baton = threading.Condition() # let thread block
# self._hasGiver = False
# self._hasTaker = False
# def give(self):
# with self._lock:
# if ( self._hasGiver ): # already?
# raise RuntimeError("Cannot double-give a baton")
# self._hasGiver = True
# self._settle() # may block, OUTSIDE self lock
# def take(self):
# with self._lock:
# if ( self._hasTaker):
# raise RuntimeError("Cannot double-take a baton")
# self._hasTaker = True
# self._settle()
# def _settle(self):
defrunThread(wt:WorkerThread):
wt.run()
classWorkerThread:
def__init__(self,pool,tid,dbState):# note: main thread context!