Skip to content

Commit

Permalink
Optimize retries strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
huangwb8 committed Jun 6, 2023
1 parent 6acfb0b commit 3ac72a1
Showing 1 changed file with 19 additions and 22 deletions.
41 changes: 19 additions & 22 deletions myblog.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,15 @@ async def main():
break
except Exception as e:
print("OOPS, the REST API mode failed!")
try:
os.remove(path_legacy_json)
os.rename(
path_legacy_json + "_temporary-copy", path_legacy_json
)
if retry < max_retries - 1:
print("Retrying...")
continue
else:
print("Maximum retries exceeded. Exiting.")
finally:
os.remove(path_legacy_json)
os.rename(
path_legacy_json + "_temporary-copy", path_legacy_json
)
if retry < max_retries - 1:
print("Retrying...")
continue
else:
print("Maximum retries exceeded. Exiting.")
sys.exit(0)
else:
if verbose:
Expand Down Expand Up @@ -159,18 +157,17 @@ async def main():
break
except Exception as e:
print("OOPS, the Password mode failed!")
try:
os.remove(path_legacy_json)
os.rename(
path_legacy_json + "_temporary-copy", path_legacy_json
)
if retry < max_retries - 1:
print("Retrying...")
continue
else:
print("Maximum retries exceeded. Exiting.")
finally:
os.remove(path_legacy_json)
os.rename(
path_legacy_json + "_temporary-copy", path_legacy_json
)
if retry < max_retries - 1:
print("Retrying...")
continue
else:
print("Maximum retries exceeded. Exiting.")
sys.exit(0)

else:
if verbose:
print("Without any new or changed legacy markdown files. Ignored.")
Expand Down

0 comments on commit 3ac72a1

Please sign in to comment.