Nov-30-2017, 08:34 PM
(This post was last modified: Nov-30-2017, 08:34 PM by jonesin1974.)
Hi,
The timeout works a treat if I hard code a value as such:
I'd like to do something along the lines of:
Many thanks,
J
The timeout works a treat if I hard code a value as such:
try: subprocess.run(['notepad.exe'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=2222) except: print("likely timeout.... Error: ", sys.exc_info()[0])I'm writing a script for CI/CD testing and depending on my application, I may want it to time out after 5 seconds, or possibly even 15 minutes. This will all get controlled by my own config file.
I'd like to do something along the lines of:
strTimeoutDuration = "5" #5 seconds. This obtained previously in my script but hard coding for this example. strTimeout = "timeout=" + strTimeoutDuration subprocess.run(['notepad.exe'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, strTimeout)Is this feasible? Last thing I want is to wait an upper limit of say 15 minutes for all applications when I know it was hanging after 10 seconds of not finishing.
Many thanks,
J