1
0
mirror of https://pagure.io/fedora-qa/os-autoinst-distri-fedora.git synced 2024-11-23 22:43:07 +00:00

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 <awilliam@redhat.com>
This commit is contained in:
Adam Williamson 2024-01-03 17:47:48 -08:00
parent 04e9f84338
commit f7a337db9e

View File

@ -342,15 +342,15 @@ def run(args):
loadargs.append('-') loadargs.append('-')
tries = 20 tries = 20
while True: while True:
ret = subprocess.run(loadargs, input=json.dumps(out), text=True, check=True) try:
if ret.returncode: subprocess.run(loadargs, input=json.dumps(out), text=True, check=True)
break
except subprocess.CalledProcessError:
if tries: if tries:
print(f"loader failed! retrying ({tries} attempts remaining)") print(f"loader failed! retrying ({tries} attempts remaining)")
tries -= 1 tries -= 1
else: else:
sys.exit("loader failed and all retries exhausted!") sys.exit("loader failed and all retries exhausted!")
else:
break
def main(): def main():
"""Main loop.""" """Main loop."""