Skip to content

Commit

Permalink
connector 的信号量初始化放在程序启动时而不是客户端启动时
Browse files Browse the repository at this point in the history
  • Loading branch information
Zzaphkiel committed Jun 24, 2024
1 parent a66ec5b commit 99e713a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
10 changes: 6 additions & 4 deletions app/lol/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@ async def wrapper(*args, **kwargs):
time.sleep(retry_sep)
exce = e

if isinstance(e, SummonerNotFound): # SummonerNotFound 再重试会报 429 (限流)
# SummonerNotFound 再重试会报 429 (限流)
if isinstance(e, SummonerNotFound):
raise e

continue
else:
break
Expand Down Expand Up @@ -199,7 +201,9 @@ class LolClientConnector(QObject):

def __init__(self):
super().__init__()
self.semaphore = None
maxRefCnt = cfg.get(cfg.apiConcurrencyNumber)

self.semaphore = asyncio.Semaphore(maxRefCnt)
self.lcuSess = None
self.sgpSess = None
self.port = None
Expand All @@ -209,15 +213,13 @@ def __init__(self):
self.inMainLand = False

self.manager = None
self.maxRefCnt = cfg.get(cfg.apiConcurrencyNumber)

self.dqLock = threading.Lock()
self.callStack = deque(maxlen=10)

async def start(self, pid):
self.pid = pid
self.port, self.token, self.server = getPortTokenServerByPid(pid)
self.semaphore = asyncio.Semaphore(self.maxRefCnt)

await self.__initSessions()
self.__initPlatformInfo()
Expand Down
5 changes: 1 addition & 4 deletions app/view/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from app.common.logger import logger
from app.common.signals import signalBus
from app.components.message_box import (UpdateMessageBox, NoticeMessageBox,
WaitingForLolMessageBox, ExceptionMessageBox)
WaitingForLolMessageBox, ExceptionMessageBox,)
from app.lol.exceptions import (SummonerGamesNotFound, RetryMaximumAttempts,
SummonerNotFound, SummonerNotInGame, SummonerRankInfoNotFound)
from app.lol.listener import (LolProcessExistenceListener, StoppableThread)
Expand Down Expand Up @@ -83,9 +83,6 @@ def __init__(self):
target=self.checkUpdate, parent=self)
self.checkNoticeThread = StoppableThread(
target=lambda: self.checkNotice(False), parent=self)
# 该功能不再支持 -- By Hpero4
# self.minimizeThread = StoppableThread(
# target=self.gameStartMinimize, parent=self)

logger.critical("Seraphine listerners started", TAG)

Expand Down

0 comments on commit 99e713a

Please sign in to comment.