fix: compact内部401刷新Token重试+清空黑名单防锁死
This commit is contained in:
1 parent
2b073f2e3f
commit
0ffbf20f6b
1 file changed
+15
@@ -660,6 +660,21 @@ def compact_endpoint():
|
|||||||
timeout=UPSTREAM_TIMEOUT_MAX, stream=False
|
timeout=UPSTREAM_TIMEOUT_MAX, stream=False
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# 401 时刷新 Token 重试
|
||||||
|
if resp.status_code == 401:
|
||||||
|
logger.warning(f"compact: 第{i+1}批收到 401,刷新Token重试...")
|
||||||
|
cache.blacklist_current()
|
||||||
|
new_token = find_token_in_memory()
|
||||||
|
if new_token:
|
||||||
|
headers['Authorization'] = f'Bearer {new_token}'
|
||||||
|
resp = http_session.request(
|
||||||
|
method='POST', url=target_url, headers=headers,
|
||||||
|
data=batch_body, allow_redirects=False,
|
||||||
|
timeout=UPSTREAM_TIMEOUT_MAX, stream=False
|
||||||
|
)
|
||||||
|
if resp.status_code == 401:
|
||||||
|
cache._blacklist.clear()
|
||||||
|
|
||||||
# compact 内部 429/504 重试
|
# compact 内部 429/504 重试
|
||||||
for _retry in range(3):
|
for _retry in range(3):
|
||||||
if resp.status_code not in (429, 504):
|
if resp.status_code not in (429, 504):
|
||||||
|
|||||||
Reference in new issue
Block a user