def get_node_health_mt(nodes_dict, check_type="normal", n_threads=8, print_out=False):
"""use multithreading to check each node health
Arguments:
nodes_dict {dict} -- [nodesIP(domainName)->(username, mem, CPU)]
Keyword Arguments:
check_type {str} -- [description] (default: {"normal"})
n_threads {number} -- [description] (default: {8})
"""
with ThreadPoolExecutor(max_workers=n_threads) as executor:
futures = {executor.submit(check_node_health, nodeinfo[0], node, check_type, print_out): node
for node, nodeinfo in nodes_dict.items()}
for future in as_completed(futures):
node = futures[future]
nodeinfo = nodes_dict[node]
result = future.result()
nodes_dict[node] = (nodeinfo[0], result)
# print("{} {}".format(node, nodes_dict[node]))
评论列表
文章目录