feat(shell): add timeout warning and faster update

see #990
This commit is contained in:
tobi-wan-kenobi 2023-09-15 15:15:31 +02:00
parent d303b794f3
commit 2e7e75a27c
2 changed files with 15 additions and 1 deletions

View file

@ -52,7 +52,19 @@ def execute(
raise RuntimeError("{} not found".format(cmd))
if wait:
out, _ = proc.communicate()
timeout = 60
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)