Some unhandled exception when running in python's subprocess.

prevent the infinite loop when the script is running in a none-interactive environment.