1
0
mirror of https://pagure.io/fedora-qa/os-autoinst-distri-fedora.git synced 2024-12-21 09:53:09 +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('-')
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."""