from Requests to HTTPX (Higher performance, I guess!)

This commit is contained in:
Remik1r3n
2025-02-06 23:30:49 +08:00
parent e73bdcda66
commit a16525c52e
8 changed files with 117 additions and 81 deletions

View File

@@ -2,7 +2,7 @@ import json
from loguru import logger
from Config import *
from API_TitleServer import apiSDGB, calcSpecialNumber, WahlapServerBoomedError, Request500Error
from API_TitleServer import *
from HelperGetUserThing import implGetUser_
from HelperUploadUserPlayLog import apiUploadUserPlaylog
from HelperUserAll import generateFullUserAll
@@ -80,16 +80,16 @@ def implFullPlayAction(userId: int, currentLoginTimestamp:int, currentLoginResul
# 开始上传 UserAll
try:
currentUserAllResult = json.loads(apiSDGB(data, "UpsertUserAllApi", userId))
except Request500Error:
except SDGBRequestError:
logger.warning("上传 UserAll 出现 500. 重建数据.")
retries += 1
continue
except Exception:
raise WahlapServerBoomedError("邪门错误")
raise SDGBApiError("邪门错误")
# 成功上传后退出循环
break
else: # 重试次数超过3次
raise Request500Error("多次尝试后仍无法成功上传 UserAll")
raise SDGBRequestError
logger.info("上机:结果:"+ str(currentUserAllResult))
return currentUserAllResult