I have the below code that kicks off an executable and waits for the response from the shell once it completes execution. I have timeout set of 60 seconds. If the executable finishes it's work within 60 seconds, the variable streamdata is a string of what would be printed to the console screen if you ran the executable interactively.
However, if the timeout cut off is reached, the value of streamdata just seems to be a blank binary string. How can I amend so that I still get the STDOUT after timeout has killed the .exe?
startupinfo = None
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
process = subprocess.Popen([<parameters>], stdout=subprocess.PIPE, startupinfo=startupinfo)
process2 = process.pid
streamdata = process.communicate(timeout=60)[0]
streamdata2 = streamdata.decode(errors='replace')
rc = process.returncode