V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
fxxkgw
V2EX  ›  程序员

Python 在多进程下读 hdfs 文件会导致 cpu load 飙升

  •  
  •   fxxkgw · 2018-11-28 18:01:51 +08:00 · 871 次点击
    这是一个创建于 1992 天前的主题,其中的信息可能已经有所发展或是发生改变。

    hdfs 集群通过 fuse_dfs 挂在本地使用

    启动多进程,每个进程中读 hdfs 下一个普通文本文件,有一定概率导致 CPU 负载 100%,挂在的 hdfs hang 住,运行 df -h 等命令卡住。

    t_file = "/hdfs/test.txt"
    def func(msg): 
        print "msg:", msg 
        # 这步有一定概率 hang 住,导致 cpu 负载 100%,挂载的 hdfs 集群不可访问。
        with open(t_file, "r") as f: 
            print f.readlines() 
        print "end.., msg = ", msg
    
    
    if __name__ == "__main__":
        pool = multiprocessing.Pool(processes = 7)
        for i in xrange(7):
            msg = "hello %d" %(i)
            pool.apply_async(func, (msg, ))
    
        pool.close()
        pool.join()
        print "done."
    
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2828 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 00:27 · PVG 08:27 · LAX 17:27 · JFK 20:27
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.