handle timeouts

Trey Moen 1 week ago
parent 3d8ca4f72f
commit 6656640d35
  1. 7
      system/hardware/tici/esim.py

@ -22,7 +22,12 @@ class LPA:
def _invoke(self, cmd): def _invoke(self, cmd):
ret = subprocess.Popen(['sudo', 'lpac', *cmd], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=self.env) ret = subprocess.Popen(['sudo', 'lpac', *cmd], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=self.env)
out, err = ret.communicate(timeout=self.timeout_sec) try:
out, err = ret.communicate(timeout=self.timeout_sec)
except subprocess.TimeoutExpired as e:
ret.kill()
raise LPAError(f"lpac {cmd} timed out after {self.timeout_sec} seconds") from e
if ret.returncode != 0: if ret.returncode != 0:
raise Exception(f"lpac {cmd} failed: {err}") raise Exception(f"lpac {cmd} failed: {err}")

Loading…
Cancel
Save