async with lock
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-10-19 20:24:47 +08:00
parent f30ad0cb7d
commit fd4c9302c2

View File

@ -157,10 +157,9 @@ class IdiomGame:
""" """
跳过当前成语,选择下一个成语 跳过当前成语,选择下一个成语
""" """
await self.lock.acquire() async with self.lock:
self._skip_idiom_async() self._skip_idiom_async()
self.add_buff_score(buff_score) self.add_buff_score(buff_score)
self.lock.release()
return self.last_idiom return self.last_idiom
def _skip_idiom_async(self) -> str: def _skip_idiom_async(self) -> str:
@ -174,9 +173,8 @@ class IdiomGame:
""" """
用户发送成语 用户发送成语
""" """
await self.lock.acquire() async with self.lock:
state = self._verify_idiom(idiom, user_id) state = self._verify_idiom(idiom, user_id)
self.lock.release()
return state return state
def is_nextable(self, last_char: str) -> bool: def is_nextable(self, last_char: str) -> bool: