上传失败后等10秒再上传
parent
0c9f9b6d3c
commit
fa97ca0eaf
|
|
@ -50,7 +50,7 @@ def upload_single_file(helper, storage_file, local_file, blob_dic, ext_meta={}):
|
|||
print(local_file + " 上传失败,尝试重试,错误信息:" + repr(e))
|
||||
upload_single_file(helper, storage_file, local_file, blob_dic, ext_meta)
|
||||
|
||||
def upload_file_with_retry(helper, storage_file, file_path, max_retries=3):
|
||||
def upload_file_with_retry(helper, storage_file, file_path, max_retries=4):
|
||||
"""带重试机制的文件上传函数"""
|
||||
for attempt in range(max_retries):
|
||||
try:
|
||||
|
|
@ -60,7 +60,7 @@ def upload_file_with_retry(helper, storage_file, file_path, max_retries=3):
|
|||
except Exception as e:
|
||||
if attempt < max_retries - 1:
|
||||
print(f"{file_path} 上传失败,尝试重试 ({attempt + 1}/{max_retries}),错误信息:{repr(e)}")
|
||||
time.sleep(2) # 重试前等待2秒
|
||||
time.sleep(10) # 重试前等待2秒
|
||||
else:
|
||||
print(f"{file_path} 上传失败,已达到最大重试次数,错误信息:{repr(e)}")
|
||||
raise
|
||||
|
|
|
|||
Loading…
Reference in New Issue