utilNode.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:multitaskLauncher 作者: 1a1a11a 项目源码 文件源码
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]))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号