What specific syntax must be changed below in order to get the call to subprocess.popen
to retry if no response is received in n
seconds?
def runShellCommand(cmd):
process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
process.wait()
The problem we are having is that the command is succeeding but the command is not receiving a response. This means that the runShellCommand(cmd)
function is just hanging forever.
If the process.wait()
lasted only n
seconds and then retried running the same cmd
, then repeated the call/wait cycle 3 or 4 times, then the function could either receive a response from one of the subsequent tries and return successful, or could fail gracefully within a specified maximum period of time.