我对用于将文件从服务器复制到 hadoop 的 python-file 感到非常困惑。
cmd是:hadoop fs -put /localhost/* /hadoop/*
代码是:
cmd = exc_path + ' ' + 'fs -put' + ' ' + src_path + item + ' ' + dst_path
process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
code = process.wait()
logfile.info('type(code) is %s, code is %s\n', type(code), code)
这几天运行正常。但是前天它返回code!=0
然后昨天,它运行正常,code == 0
然后今天它失败并返回:type(code) is <type 'int'>, code is 255
文档说wait()
应该返回 0 或 None,那么为什么我会得到 255?并且 hadoop 的 cmd 'put' 应该返回 0(成功时)和 -1(失败时)。
我发现了一些有用的信息:“遗憾的是,当使用 shell=True 运行子进程时,wait() 只会等待 sh 子进程完成,而不是等待命令 cmd。” 从