def get(self, *args, **kwargs): threads = [] node_update = threading.Thread(target=self._update_node) threads.append(node_update) node_pass = threading.Thread(target=self._get_pass) #此函数在于构成for循环,用于异构 threads.append(node_pass) for t in threads: t.setDaemon(True) t.start() node_data = NodeInfo.node_info() node_data_handled = DataManage.manage_node_info( node_data) #对数据按页面要求的格式做格式化 self.render("node/node_manage.html", node_data=node_data_handled)
def _update_node(self): node_data = NodeInfo.node_info() #获取Node节点信息 myswarm = Myswarm() for line in node_data: node_ip = line[2] node_port = line[3] if myswarm.ping_port(node_ip, node_port) == 0: node_info = myswarm.node_info(node_ip, node_port) NodeInfo.update_node_info( node_info, myswarm.ping_port(node_ip, node_port), node_ip) else: NodeInfo.update_node_state( myswarm.ping_port(node_ip, node_port), node_ip, node_port) continue