fix: 401 黑名单锁死 - 新Token也401时清空黑名单避免27分钟不可用
This commit is contained in:
1 parent
5899032aee
commit
29d6fac6cc
1 file changed
+19
@@ -879,6 +879,25 @@ def proxy(subpath):
|
||||
timeout=upstream_timeout,
|
||||
stream=True
|
||||
)
|
||||
# 如果新 Token 也 401,清空黑名单避免锁死
|
||||
if resp.status_code == 401:
|
||||
resp.close()
|
||||
logger.warning("新 Token 也 401,清空黑名单避免锁死")
|
||||
cache._blacklist.clear()
|
||||
# 再试一次
|
||||
new_token2 = find_token_in_memory()
|
||||
if new_token2:
|
||||
headers['Authorization'] = f'Bearer {new_token2}'
|
||||
resp = http_session.request(
|
||||
method=request.method,
|
||||
url=target_url,
|
||||
headers=headers,
|
||||
data=raw_body,
|
||||
cookies=request.cookies,
|
||||
allow_redirects=False,
|
||||
timeout=upstream_timeout,
|
||||
stream=True
|
||||
)
|
||||
|
||||
# ============ 429 限流重试 ============
|
||||
if resp.status_code == 429:
|
||||
|
||||
Reference in new issue
Block a user