forked from mttu-developers/konabot
async with lock
This commit is contained in:
@ -157,10 +157,9 @@ class IdiomGame:
|
||||
"""
|
||||
跳过当前成语,选择下一个成语
|
||||
"""
|
||||
await self.lock.acquire()
|
||||
self._skip_idiom_async()
|
||||
self.add_buff_score(buff_score)
|
||||
self.lock.release()
|
||||
async with self.lock:
|
||||
self._skip_idiom_async()
|
||||
self.add_buff_score(buff_score)
|
||||
return self.last_idiom
|
||||
|
||||
def _skip_idiom_async(self) -> str:
|
||||
@ -174,9 +173,8 @@ class IdiomGame:
|
||||
"""
|
||||
用户发送成语
|
||||
"""
|
||||
await self.lock.acquire()
|
||||
state = self._verify_idiom(idiom, user_id)
|
||||
self.lock.release()
|
||||
async with self.lock:
|
||||
state = self._verify_idiom(idiom, user_id)
|
||||
return state
|
||||
|
||||
def is_nextable(self, last_char: str) -> bool:
|
||||
|
||||
Reference in New Issue
Block a user