proc.communicate not exiting on python subprocess timeout -
the script below (a python process called, calls waitfor cmd timeout of 4 seconds) supposed end after 4 seconds. instead proc.communicate stops after 20 seconds timeout.
why???
if __name__ == "__main__": proc_str = ["c:\\program files (x86)\\anaconda3\\python.exe", "-c", "import subprocess;subprocess.run('cmd /s /c waitfor g /t 200', shell=false, timeout=4)"] proc = subprocess.popen(proc_str, stdin=subprocess.pipe, stderr=subprocess.pipe, stdout=subprocess.pipe, shell=false, universal_newlines=true) (proc_out, proc_err) = proc.communicate(timeout=20) if (proc.returncode == 0): pass
everything works 100% ok if remove stdin/stderr/stdout parameters
Comments
Post a Comment