def __init__(self, worker_id, neptune_client, pipe_c2s, pipe_s2c, model, dummy, predictor_threads, predict_batch_size=16, do_train=True): # predictor_threads is previous PREDICTOR_THREAD super(MySimulatorMaster, self).__init__(pipe_c2s, pipe_s2c, args.simulator_procs, os.getpid()) self.M = model self.do_train = do_train # the second queue is here! self.queue = queue.Queue(maxsize=args.my_sim_master_queue) self.dummy = dummy self.predictor_threads = predictor_threads self.last_queue_put = start_timer() self.queue_put_times = [] self.predict_batch_size = predict_batch_size self.counter = 0 self.worker_id = worker_id self.neptune_client = neptune_client self.stats = defaultdict(StatCounter) self.games = StatCounter()
def log_queue_put(self): self.counter += 1 elapsed_last_put = elapsed_time_ms(self.last_queue_put) self.queue_put_times.append(elapsed_last_put) k = 1000 if self.counter % 1 == 0: logger.debug("queue_put_times elapsed {elapsed}".format(elapsed=elapsed_last_put)) logger.debug("queue_put_times {puts_s} puts/s".format(puts_s=1000.0 / np.mean(self.queue_put_times[-k:]))) self.last_queue_put = start_timer()