perf: 优化线程锁相关操作

This commit is contained in:
Rock Chin
2022-12-13 16:04:51 +08:00
parent 00abab8050
commit b70a2da2ef
3 changed files with 12 additions and 5 deletions

View File

@@ -225,10 +225,12 @@ class QQBotManager:
reply = self.process_message('person', event.sender.id, str(event.message_chain))
break
except FunctionTimedOut:
pkg.openai.session.get_session('person_{}'.format(event.sender.id)).release_response_lock()
failed += 1
continue
if failed == self.retry:
pkg.openai.session.get_session('person_{}'.format(event.sender.id)).release_response_lock()
self.notify_admin("{} 请求超时".format("person_{}".format(event.sender.id)))
reply = "[bot]err:请求超时"