0

I am using subprocess.poll to read the status of standard out and error.

while subprocess.poll() is None :
    out = subprocess.stdout.readline()
        print out

Process comes out of loop before job exection completes. how can i wait till job finishes?

cripki
  • 1
  • 1

1 Answers1

0

It is perfectly possible for a program to have finished before you have read all of the available output. poll() returns None while the program is not finished, but if you need to read all of its output, you may need to keep going even after poll() returns the exit code.

It looks like you are looking for subprocess.communicate() instead.

tripleee
  • 175,061
  • 34
  • 275
  • 318
  • Hello Tripleee, I would like to read data from cmd line by line to make sure that some of the process are called. subprocess.communicate provides the data together at the end. Is there any other way to read the data? – cripki Jun 10 '16 at 06:17
  • Sounds like you are looking for http://stackoverflow.com/questions/1822237/asynchronously-read-stdout-from-subprocess-popen – tripleee Jun 10 '16 at 07:25