cmd = 'hadoop fs -cat {f}|head -1'.format(f=file_name)
process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=
    subprocess.PIPE)
stdout, stderr = process.communicate()
if stderr != '':
    file_line = stdout.split('\n')[0]
else:
    print("####Exception '{e}' in reading file {f}".format(f=file_name, e=
        stdout))
continue
Pydoop stucks on readline from HDFS files