diff --git a/ai/huawei_gateway.py b/ai/huawei_gateway.py index df4cca1..f226313 100755 --- a/ai/huawei_gateway.py +++ b/ai/huawei_gateway.py @@ -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: