fix: music_with_retry need only userId params.

This commit is contained in:
7a1dd609-d238-4580-9d5f-ee8412b0f5bc 2025-01-11 02:00:31 +08:00
parent bfa29f669f
commit cf4fa84616
2 changed files with 12 additions and 14 deletions

View File

@ -384,16 +384,15 @@ def music(userId):
userall_result = json.loads(sdgb_api(data, "UpsertUserAllApi", userId))
return userall_result
def music_with_retry(userId, max_retries=10): # 这里是重试次数
for i in range(max_retries):
def music_with_retry(userId):
for i in range(5): # 重试次数
try:
print(music(userId))
music(userId)
return logout(userId, timestamp)
except ValueError as e:
print(f"尝试 {i+1} 失败,错误:{e}")
print(logout(userId, timestamp))
time.sleep(5) # 等待 5 秒后重试
return "重试次数超过限制,乐曲上传失败"
logout(userId, timestamp)
time.sleep(3) # 等待 5 秒后重试
return "Error"
if __name__ == "__main__":
print(music_with_retry())

View File

@ -7501,16 +7501,15 @@ def music(userId):
userall_result = json.loads(sdgb_api(data, "UpsertUserAllApi", userId))
return userall_result
def music_with_retry(userId, max_retries=10): # 这里是重试次数
for i in range(max_retries):
def music_with_retry(userId):
for i in range(5): # 重试次数
try:
print(music(userId))
music(userId)
return logout(userId, timestamp)
except ValueError as e:
print(f"尝试 {i+1} 失败,错误:{e}")
print(logout(userId, timestamp))
time.sleep(5) # 等待 5 秒后重试
return "重试次数超过限制,乐曲上传失败"
logout(userId, timestamp)
time.sleep(3) # 等待 5 秒后重试
return "Error"
if __name__ == "__main__":
print(music_with_retry())