The task I try to accomplish is to stream a ruby file and print out the output. (NOTE: I don\'t want to print out everything at once)
Try this:
proc = Popen(command, bufsize=0, shell=True, stdout=PIPE, close_fds=True)
for line in proc.stdout:
print line
print("This is most certainly reached!")
As others have noted, readline()
will block when reading data. It will even do so when your child process has died. I am not sure why this does not happen when executing ls
as in the other answer, but maybe the ruby interpreter detects that it is writing to a PIPE and therefore it will not close automatically.