Skip to content

Commit

Permalink
暂时移除定时获取token
Browse files Browse the repository at this point in the history
  • Loading branch information
Hobr committed Jun 30, 2024
1 parent 9bd476c commit 9bf2dea
Showing 1 changed file with 9 additions and 22 deletions.
31 changes: 9 additions & 22 deletions util/Task/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,6 @@ def __init__(
conditions=lambda: self.createStatusResult is False,
)

# 上次刷新时间
self.lastTime = 0
# 是否已缓存getV2
self.queryCache = False

Expand Down Expand Up @@ -222,25 +220,17 @@ def QueryTokenAction(self) -> None:
返回值: 0-成功, 1-风控, 2-未开票, 3-未知
"""
# 超过9分钟 / Token刷新失败重新获取Token / 验证结束重新获取Token / 创建订单时Token失效重新获取Token
if time() >= self.lastTime + 9 * 60 or self.queryTokenResult == 2 or self.riskProcessResult or self.createOrderResult == 1:
logger.info("【刷新Token】开始刷新")
self.lastTime = time()
self.queryTokenResult = self.api.QueryToken()
self.riskProcessResult = False
self.createOrderResult = 0

# 顺路
if not self.queryCache:
logger.info("【刷新Token】已缓存商品信息")
self.api.QueryAmount()
self.queryCache = True
self.queryTokenResult = self.api.QueryToken()

# 防风控
else:
sleep(self.sleep)
# 顺路
if not self.queryCache:
logger.info("【刷新Token】已缓存商品信息")
self.api.QueryAmount()
self.queryCache = True

# 防风控
else:
logger.warning("【刷新Token】未到9分钟/未满足抢票条件, 不刷新Token")
sleep(self.sleep)

@logger.catch
def RiskProcessAction(self) -> None:
Expand Down Expand Up @@ -320,7 +310,4 @@ def Run(self) -> bool:
while self.state != "完成": # type: ignore
sleep(0.15)
self.trigger(job[self.state]) # type: ignore
if time() >= self.lastTime + 9 * 60:
logger.info("【刷新Token】已经9分钟没刷新Token了! 尝试刷新")
self.to_获取Token() # type: ignore
return True

0 comments on commit 9bf2dea

Please sign in to comment.