• 请不要在回答技术问题时复制粘贴 AI 生成的内容
fxxkgw
V2EX  ›  程序员

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

  •  
  •   fxxkgw · Nov 28, 2018 · 1214 views
    This topic created in 2727 days ago, the information mentioned may be changed or developed.

    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."
    
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3021 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 15:12 · PVG 23:12 · LAX 08:12 · JFK 11:12
    ♥ Do have faith in what you're doing.