Skip to content

Commit

Permalink
fix: 取消提前获取token 避免倒计时后爆炸
Browse files Browse the repository at this point in the history
  • Loading branch information
Hobr committed Sep 30, 2024
1 parent e08ac47 commit 5ddf4a4
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 16 deletions.
Binary file modified assest/fsm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 1 addition & 16 deletions util/Task/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,10 @@ def __init__(
)

# 等待开票结束
self.machine.add_transition(
trigger="WaitAvailable",
source="等待开票",
dest="创建订单",
# 倒计时30s时已获取Token
conditions=lambda: self.skipToken,
)
self.machine.add_transition(
trigger="WaitAvailable",
source="等待开票",
dest="获取Token",
# 无倒计时, 开始获取Token
conditions=lambda: not self.skipToken,
)

# 获取Token结束
Expand Down Expand Up @@ -161,6 +152,7 @@ def __init__(
conditions=lambda: self.riskProcessCode != 0,
)

# 等待余票结束
self.machine.add_transition(
trigger="QueryTicket",
source="等待余票",
Expand Down Expand Up @@ -280,13 +272,6 @@ def WaitAvailableAction(self) -> None:
sleep(5)
countdown -= 5

elif countdown == 30:
logger.info("【等待开票】即将开票! 正在提前获取Token...")
self.QueryTokenAction()
self.skipToken = True
if self.queryTokenCode == -401:
self.RiskProcessAction()

elif 60 > countdown > 1:
logger.info(f"【等待开票】即将开票! 需要等待 {countdown-1} 秒")
sleep(1)
Expand Down

0 comments on commit 5ddf4a4

Please sign in to comment.