Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复以及优化 #80

Merged
merged 4 commits into from
Sep 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/lol/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,22 @@ def decorator(func):
def wrapper(*args, **kwargs):
exce = None
for _ in range(count):
while connector.ref_cnt >= 3:
time.sleep(.2)

connector.ref_cnt += 1
try:
res = func(*args, **kwargs)
except BaseException as e:
connector.ref_cnt -= 1
time.sleep(retry_sep)
exce = e
continue
else:
connector.ref_cnt -= 1
break
else:
connector.ref_cnt -= 1
connector.timeoutApi = func.__name__
raise exce
# raise Exception("Exceeded maximum retry attempts.")
Expand All @@ -66,6 +73,9 @@ def __init__(self):
self.token = None
self.url = None

# 并发数过高时会导致LCU闪退
# 通过引用计数避免 (不大于3个并发)
self.ref_cnt = 0
self.tackleFlag = threading.Event()
self.manager = None

Expand Down
5 changes: 4 additions & 1 deletion app/view/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,9 @@ def __onGameStatusChanged(self, status):
isGaming = True
elif status == 'InProgress':
title = self.tr("Gaming")
self.__onGameStart()
# 重连或正常进入游戏(走GameStart), 不需要更新数据
if not self.isGaming:
self.__onGameStart()
isGaming = True
elif status == 'WaitingForStatus':
title = self.tr("Waiting for status")
Expand All @@ -810,6 +812,7 @@ def __onGameStatusChanged(self, status):
elif status == 'Lobby':
title = self.tr("Lobby")
self.__onGameEnd()
self.switchTo(self.careerInterface)
elif status == 'ReadyCheck':
title = self.tr("Ready check")
self.__onMatchMade()
Expand Down
9 changes: 5 additions & 4 deletions app/view/search_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,14 @@ def updateNextPageTabs(self, data):
self.stackWidget.setCurrentIndex(self.currentIndex)
self.pageLabel.setText(f"{self.currentIndex}")

if self.first:
if self.triggerGameId:
self.tabClicked.emit(str(self.triggerGameId))
self.triggerGameId = 0
elif self.first:
gameId = layout.itemAt(0).widget().gameId
self.tabClicked.emit(str(gameId))
self.first = False
elif self.triggerGameId:
self.tabClicked.emit(str(self.triggerGameId))
self.triggerGameId = 0


mainWindow = self.window()
mainWindow.checkAndSwitchTo(mainWindow.searchInterface)
Expand Down