def logging(self): """Log activity during duration.""" duration = self.duration end_time = time.time() + duration trace("* Logging for %ds (until %s): " % (duration, datetime.fromtimestamp(end_time).isoformat())) set_recording_flag(True) while time.time() < end_time: # wait time.sleep(1) set_recording_flag(False) trace(" done.\n")
def startThreads(self, cycle, number_of_threads): """Starts threads.""" self.thread_creation_lock.acquire() try: trace("* Current time: %s\n" % datetime.now().isoformat()) trace("* Starting threads: ") set_recording_flag(False) threads = self.createThreads(cycle, number_of_threads) self.threads.extend(threads) finally: set_recording_flag(True) self.thread_creation_lock.release()
def addThreads(self, number_of_threads): """Adds new threads to existing list. Used to dynamically add new threads during a debug bench run.""" self.thread_creation_lock.acquire() try: trace("Adding new threads: ") set_recording_flag(False) # In debug bench, 'cycle' value is irrelevant. threads = self.createThreads(0, number_of_threads) self.threads.extend(threads) finally: set_recording_flag(True) self.thread_creation_lock.release()