Davidliu 3 months ago
parent
commit
446bc28f27
1 changed files with 3 additions and 1 deletions
  1. 3 1
      src/core/voip/bot.py

+ 3 - 1
src/core/voip/bot.py

@@ -466,6 +466,7 @@ class ToTextBotAgent:
                     traceback.print_exc()
                     self.call_agent.logger.error(f"TaskId={request.taskId}, 请求发生异常 {e}, URL: {url}")
                 finally:
+                    try_count = try_count - 1
                     latency = (time.time() - once_start)
                     registry.BOT_REQUEST_ONCE_LATENCY.labels(request.taskId).observe(latency)
 
@@ -494,7 +495,6 @@ class ToTextBotAgent:
                 while try_count > 0:
                     once_start = time.time()
                     try:
-                        try_count = try_count - 1
                         response = session.post(url=url, json=payload, timeout=3)
                         # response = requests.post(url=url,  json=json.loads(request_data), headers=headers, timeout=10)  # 使用占位URL
                         self.call_agent.logger.info("to_request come in , try_count=%s", try_count)
@@ -513,8 +513,10 @@ class ToTextBotAgent:
                         traceback.print_exc()
                         self.call_agent.logger.error(f"TaskId={request.taskId}, 请求发生异常: {e}, URL: {url}")
                     finally:
+                        try_count = try_count - 1
                         latency = (time.time() - once_start)
                         registry.BOT_REQUEST_ONCE_LATENCY.labels(request.taskId).observe(latency)
+
                 if not message:
                     message = self.get_default_response()
                     self.call_agent.message_queue.put(message)