From f7a337db9efb45c12162950c39432c84db66f9e7 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Wed, 3 Jan 2024 17:47:48 -0800 Subject: [PATCH] Fix the retry logic in fifloader.py subprocess.run raises an exception by default if the command fails, you don't have to look for the return code. Signed-off-by: Adam Williamson --- fifloader.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fifloader.py b/fifloader.py index ea3ac0e1..3b1eb43b 100755 --- a/fifloader.py +++ b/fifloader.py @@ -342,15 +342,15 @@ def run(args): loadargs.append('-') tries = 20 while True: - ret = subprocess.run(loadargs, input=json.dumps(out), text=True, check=True) - if ret.returncode: + try: + subprocess.run(loadargs, input=json.dumps(out), text=True, check=True) + break + except subprocess.CalledProcessError: if tries: print(f"loader failed! retrying ({tries} attempts remaining)") tries -= 1 else: sys.exit("loader failed and all retries exhausted!") - else: - break def main(): """Main loop."""