I have a python script which executes the following command using subprocess, but it gets stuck when some error occurs:
import subprocess
COMMAND = " Application.exe arg1 arg2"
process = subprocess.Popen(COMMAND, stdout=subprocess.PIPE, stderr=None, shell=True)
while process.poll() is None:
output = process.stdout.readline()
print output,
output:
There was a communication problem.
Failed.Press enter to exit...
Because of the above output, my program is not able to exit until I press any key manually. Please help show me how to handle the above response and exit my code. The above program works good if there is no error.