mirror of
http://112.124.100.131/huang.ze/ebiz-dify-ai.git
synced 2025-12-11 11:56:53 +08:00
Concurrent calls to the Wenxin model, and the exception problem when obtaining the token is fixed (#7976)
Co-authored-by: puqs1 <puqs1@lenovo.com>
This commit is contained in:
@@ -79,11 +79,13 @@ class BaiduAccessToken:
|
|||||||
# if access token not in cache, request it
|
# if access token not in cache, request it
|
||||||
token = BaiduAccessToken(api_key)
|
token = BaiduAccessToken(api_key)
|
||||||
baidu_access_tokens[api_key] = token
|
baidu_access_tokens[api_key] = token
|
||||||
# release it to enhance performance
|
try:
|
||||||
# btw, _get_access_token will raise exception if failed, release lock here to avoid deadlock
|
# try to get access token
|
||||||
baidu_access_tokens_lock.release()
|
token_str = BaiduAccessToken._get_access_token(api_key, secret_key)
|
||||||
# try to get access token
|
finally:
|
||||||
token_str = BaiduAccessToken._get_access_token(api_key, secret_key)
|
# release it to enhance performance
|
||||||
|
# btw, _get_access_token will raise exception if failed, release lock here to avoid deadlock
|
||||||
|
baidu_access_tokens_lock.release()
|
||||||
token.access_token = token_str
|
token.access_token = token_str
|
||||||
token.expires = now + timedelta(days=3)
|
token.expires = now + timedelta(days=3)
|
||||||
return token
|
return token
|
||||||
|
|||||||
Reference in New Issue
Block a user