def listdirx(dirname='.', cmd='ls'):
    proc = subprocess.Popen([cmd, dirname], stdout=subprocess.PIPE)
filename = proc.stdout.readline()
while filename != '':
    yield filename.rstrip('\n')
filename = proc.stdout.readline()
proc.communicate()
List files in a folder as a stream to begin process immediately