Skip to content

Commit

Permalink
fix: handle upload failures and retry
Browse files Browse the repository at this point in the history
  • Loading branch information
Ovler-Young committed Jun 19, 2024
1 parent 7b2300d commit aa7c693
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions biliarchiver/_biliarchiver_upload_bvid.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,15 +232,25 @@ def _upload_bvid(
print(md)

if filedict:
r = item.upload(
files=filedict,
metadata=md,
access_key=access_key,
secret_key=secret_key,
verbose=True,
queue_derive=True,
retries=5,
)
upload_retry = 5
while upload_retry > 0:
try:
r = item.upload(
files=filedict,
metadata=md,
access_key=access_key,
secret_key=secret_key,
verbose=True,
queue_derive=True,
retries=5,
)
break
except Exception as e:
print(e)
upload_retry -= 1
print(f"Upload failed, retrying ({upload_retry}) ...")
time.sleep(30)
assert upload_retry > 0, "Upload failed"

tries = 100
item = get_item(remote_identifier) # refresh item
Expand Down

0 comments on commit aa7c693

Please sign in to comment.