2

I'm using popen to run a subprocess in python. I need to read each line the subprocess outputs as it is being outputted, rather then getting everything once the process terminates. I've tried everything I could find on Google with no success. Any help would be greatly appreciated.

lime
  • 21
  • 1
  • Closely related: http://stackoverflow.com/questions/1544050/force-another-programs-standard-output-to-be-unbuffered-using-python – Sven Marnach Jun 09 '11 at 15:42

1 Answers1

1

The subprocess.Popen documentation describes the available arguments to its call.

You want to set the bufsize argument to 1 (line-buffered input/output).

tzot
  • 92,761
  • 29
  • 141
  • 204