def on_new_answer(self, command): while True: msg = recvAll(command, msgLength) if (msg != b''): file = io.BytesIO(msg) while True: try: entry = pickle.load(file) # print(entry) msgType = entry[0] msg = entry[2] slaveId = entry[1] if msgType == "done": self.working.append(slaveId) self.maxBlock = max(self.maxBlock, msg[0]) self.maxTime = max(self.maxTime, msg[1]) elif msgType == "answer": if self.answerNum[msg[0]] == 0: if type(msg[1]) == float: self.answer.append(0.0) elif type(msg[1]) == int: self.answer.append(0) else: self.answer.append([]) self.answerNum[msg[0]] += 1 if type(msg[1]) == type({}): self.answer[msg[0]] += list(msg[1].items()) continue self.answer[msg[0]] += msg[1] elif msgType == "new": self.plot_update(msg) except EOFError: break
def on_update_block(self, package): while True: print('update') rawblk = recvAll(package) blk = pickle.load(io.BytesIO(rawblk)) self.tree.update(blk) self.mapping.update(blk) self.draw_min()
def on_new_query(self, command, addr): while True: msg = recvAll(command, msgLength) if (msg != b''): file = io.BytesIO(msg) while True: try: entry = pickle.load(file) # print(entry) # query type, start,end command.sendall( pickle.dumps( self.query(entry[0], entry[1], entry[2]))) except EOFError: break
def on_new_command( self, command, ): while True: msg = recvAll(command, msgLength) if (msg != b''): file = io.BytesIO(msg) while True: try: entry = pickle.load(file) if entry[0] == "query": answer = self.query(entry[1], entry[2]) self.sendBack(answer, entry[3]) except EOFError: break
def on_new_query(self, command, addr): while True: msg = recvAll(command, msgLength) if (msg != b''): file = io.BytesIO(msg) while True: try: entry = pickle.load(file) # print(entry) # query type, start,end if entry[0] == "get": while self.answerNum[entry[2] - 1] < slave_num: time.sleep(0.5) command.sendall( pickle.dumps(self.answer[entry[1]:entry[2]])) else: self.query(entry[0], entry[1], entry[2]) except EOFError: break