到达上限时也应该增加未解决错误。
This commit is contained in:
@@ -325,9 +325,7 @@ class Agent:
|
|||||||
)
|
)
|
||||||
|
|
||||||
if retry_count > 0:
|
if retry_count > 0:
|
||||||
self.logger.info(
|
self.logger.info(f"重试成功 (第 {retry_count}/{self.retry} 次尝试)。")
|
||||||
f"重试成功 (第 {retry_count}/{self.retry} 次尝试)。"
|
|
||||||
)
|
|
||||||
|
|
||||||
# print(f"result:=============================================================\n{result}\n================\n")
|
# print(f"result:=============================================================\n{result}\n================\n")
|
||||||
return (
|
return (
|
||||||
@@ -372,6 +370,9 @@ class Agent:
|
|||||||
if retry_count == 0:
|
if retry_count == 0:
|
||||||
if self.total_error_counter.add():
|
if self.total_error_counter.add():
|
||||||
self.logger.error("错误次数过多,已达到上限,不再重试。")
|
self.logger.error("错误次数过多,已达到上限,不再重试。")
|
||||||
|
# 新增:当因为达到错误上限而不再重试时,增加未解决错误计数
|
||||||
|
with self.unresolved_error_lock:
|
||||||
|
self.unresolved_error_count += 1
|
||||||
return (
|
return (
|
||||||
best_partial_result
|
best_partial_result
|
||||||
if best_partial_result
|
if best_partial_result
|
||||||
@@ -383,6 +384,9 @@ class Agent:
|
|||||||
)
|
)
|
||||||
elif self.total_error_counter.reach_limit():
|
elif self.total_error_counter.reach_limit():
|
||||||
self.logger.error("错误次数过多,已达到上限,不再为该请求重试。")
|
self.logger.error("错误次数过多,已达到上限,不再为该请求重试。")
|
||||||
|
# 新增:当因为达到错误上限而不再重试时,增加未解决错误计数
|
||||||
|
with self.unresolved_error_lock:
|
||||||
|
self.unresolved_error_count += 1
|
||||||
return (
|
return (
|
||||||
best_partial_result
|
best_partial_result
|
||||||
if best_partial_result
|
if best_partial_result
|
||||||
@@ -463,6 +467,7 @@ class Agent:
|
|||||||
async with httpx.AsyncClient(
|
async with httpx.AsyncClient(
|
||||||
trust_env=False, proxies=proxies, verify=False, limits=limits
|
trust_env=False, proxies=proxies, verify=False, limits=limits
|
||||||
) as client:
|
) as client:
|
||||||
|
|
||||||
async def send_with_semaphore(p_text: str):
|
async def send_with_semaphore(p_text: str):
|
||||||
async with semaphore:
|
async with semaphore:
|
||||||
result = await self.send_async(
|
result = await self.send_async(
|
||||||
@@ -546,9 +551,7 @@ class Agent:
|
|||||||
)
|
)
|
||||||
|
|
||||||
if retry_count > 0:
|
if retry_count > 0:
|
||||||
self.logger.info(
|
self.logger.info(f"重试成功 (第 {retry_count}/{self.retry} 次尝试)。")
|
||||||
f"重试成功 (第 {retry_count}/{self.retry} 次尝试)。"
|
|
||||||
)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
result
|
result
|
||||||
@@ -590,6 +593,9 @@ class Agent:
|
|||||||
if retry_count == 0:
|
if retry_count == 0:
|
||||||
if self.total_error_counter.add():
|
if self.total_error_counter.add():
|
||||||
self.logger.error("错误次数过多,已达到上限,不再重试。")
|
self.logger.error("错误次数过多,已达到上限,不再重试。")
|
||||||
|
# 新增:当因为达到错误上限而不再重试时,增加未解决错误计数
|
||||||
|
with self.unresolved_error_lock:
|
||||||
|
self.unresolved_error_count += 1
|
||||||
return (
|
return (
|
||||||
best_partial_result
|
best_partial_result
|
||||||
if best_partial_result
|
if best_partial_result
|
||||||
@@ -601,6 +607,9 @@ class Agent:
|
|||||||
)
|
)
|
||||||
elif self.total_error_counter.reach_limit():
|
elif self.total_error_counter.reach_limit():
|
||||||
self.logger.error("错误次数过多,已达到上限,不再为该请求重试。")
|
self.logger.error("错误次数过多,已达到上限,不再为该请求重试。")
|
||||||
|
# 新增:当因为达到错误上限而不再重试时,增加未解决错误计数
|
||||||
|
with self.unresolved_error_lock:
|
||||||
|
self.unresolved_error_count += 1
|
||||||
return (
|
return (
|
||||||
best_partial_result
|
best_partial_result
|
||||||
if best_partial_result
|
if best_partial_result
|
||||||
|
|||||||
Reference in New Issue
Block a user