Skip to content

Commit

Permalink
Merge pull request #80 from Hpero4/main
Browse files Browse the repository at this point in the history
修复以及优化
  • Loading branch information
Zzaphkiel authored Sep 24, 2023
2 parents cae3ffe + 4ef2d4f commit 8be7dc2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
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

0 comments on commit 8be7dc2

Please sign in to comment.