Adding shell command execution on click for shell module

This commit is contained in:
Andrei Lando 2023-09-12 16:36:37 +04:00
parent fded39fa81
commit 9b2ac5d521
2 changed files with 50 additions and 3 deletions

View file

@ -52,7 +52,17 @@ def execute(
raise RuntimeError("{} not found".format(cmd))
if wait:
out, _ = proc.communicate()
timeout = 60 # seconds
try:
out, _ = proc.communicate(timeout=timeout)
except subprocess.TimeoutExpired as e:
logging.warning(f'''
Communication with process pid={proc.pid} hangs for more
than {timeout} seconds.
If this is not expected, the process is stale, or
you might have run in stdout / stderr deadlock.
''')
out, _ = proc.communicate()
if proc.returncode != 0:
err = "{} exited with code {}".format(cmd, proc.returncode)
logging.warning(err)