Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

Concurrent calls to the Wenxin model, and the exception problem when obtaining the token is fixed (#7976)

wochuidengf6b9982c23d1
diff --git a/api/core/model_runtime/model_providers/wenxin/_common.py b/api/core/model_runtime/model_providers/wenxin/_common.py
index 0230c78b757..017856bdde2 100644
--- a/api/core/model_runtime/model_providers/wenxin/_common.py
+++ b/api/core/model_runtime/model_providers/wenxin/_common.py
@@ -79,11 +79,13 @@ class BaiduAccessToken:
# if access token not in cache, request it
token = BaiduAccessToken(api_key)
baidu_access_tokens[api_key] = token
- # 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()
- # try to get access token
- token_str = BaiduAccessToken._get_access_token(api_key, secret_key)
+ try:
+ # try to get access token
+ token_str = BaiduAccessToken._get_access_token(api_key, secret_key)
+ finally:
+ # 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.expires = now + timedelta(days=3)
return token