fixed crash on failed command execution
This commit is contained in:
parent
ec0fe9db5c
commit
aa3aef7be0
@ -12,6 +12,9 @@ def exec_cmd(cmd, timeout=900, env = None):
|
|||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE,
|
stderr=subprocess.PIPE,
|
||||||
env = env)
|
env = env)
|
||||||
|
out = b""
|
||||||
|
err = b""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
out, err = proc.communicate(timeout=timeout)
|
out, err = proc.communicate(timeout=timeout)
|
||||||
except subprocess.TimeoutExpired as err:
|
except subprocess.TimeoutExpired as err:
|
||||||
@ -22,7 +25,6 @@ def exec_cmd(cmd, timeout=900, env = None):
|
|||||||
log.error('Command "{}" would not be killed, forcing a termination'.format(' '.join(cmd)))
|
log.error('Command "{}" would not be killed, forcing a termination'.format(' '.join(cmd)))
|
||||||
proc.terminate()
|
proc.terminate()
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
|
|
||||||
return (proc.returncode, out.decode('utf-8'), err.decode('utf-8'))
|
return (proc.returncode, out.decode('utf-8'), err.decode('utf-8'))
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user