添加获取图片的超时和重试,防止一直获取而导致程序卡住
This commit is contained in:
@@ -15,7 +15,7 @@ def get_private_url(key, bucket=BUCKET):
|
||||
_, resp = UFILE_HANDLER.head_file(bucket, key)
|
||||
if resp.status_code == -1:
|
||||
logging.warning(f"uCloud连接失败!即将重试...")
|
||||
sleep(1)
|
||||
sleep(3)
|
||||
continue
|
||||
if resp.status_code != 200:
|
||||
logging.warning(f"uCloud中未找到({key})! status: {resp.status_code} error: {resp.error}")
|
||||
@@ -35,7 +35,7 @@ def copy_file(source_bucket, source_key, target_bucket, target_key):
|
||||
ret, resp = UFILE_HANDLER.copy(target_bucket, target_key, source_bucket, source_key)
|
||||
if resp.status_code == -1:
|
||||
logging.warning(f"uCloud连接失败!即将重试...")
|
||||
sleep(1)
|
||||
sleep(3)
|
||||
continue
|
||||
if resp.status_code != 200:
|
||||
logging.warning(
|
||||
@@ -50,7 +50,7 @@ def upload_file(key, file_path, bucket=BUCKET):
|
||||
ret, resp = UFILE_HANDLER.putfile(bucket, key, file_path, header=None)
|
||||
if resp.status_code == -1:
|
||||
logging.warning(f"uCloud连接失败!即将重试...")
|
||||
sleep(1)
|
||||
sleep(3)
|
||||
continue
|
||||
if resp.status_code != 200:
|
||||
logging.warning(f"上传({key})失败! status: {resp.status_code} error: {resp.error}")
|
||||
|
||||
Reference in New Issue
Block a user