余尚辉 20 ساعت پیش
والد
کامیت
3efca945d2
1فایلهای تغییر یافته به همراه8 افزوده شده و 8 حذف شده
  1. 8 8
      src/core/callcenter/esl/client.py

+ 8 - 8
src/core/callcenter/esl/client.py

@@ -95,13 +95,7 @@ class InboundClient:
                     self.start()
                 else:
                     # threading.Thread(target=self.process_esl_event, args=(e,)).start()
-                    # self.choose_thread_pool_executor(e).submit(self.process_esl_event, e)
-                    try:
-                        executor = self.choose_thread_pool_executor(e)
-                        print("Executor obtained:", executor)
-                        executor.submit(self.process_esl_event, e)
-                    except Exception as ex:
-                        print(f"Error occurred while submitting task: {ex}")
+                    self.choose_thread_pool_executor(e).submit(self.process_esl_event, e)
 
     def choose_thread_pool_executor(self, e):
         call_id = EslEventUtil.getCallId(e)
@@ -113,7 +107,13 @@ class InboundClient:
         else:
             random_index = random.randint(0, len(self.executors) - 1) if self.executors else 0
         # print('choose_thread_pool_executor.index=', random_index, call_id, device_id, wdh_device_id)
-        return self.executors.get(random_index)
+            # 获取执行器
+        executor = self.executors.get(random_index)
+        if executor is None:  # 如果未找到,打印日志并返回备用执行器
+            self.logger.error(f"Executor not found for index {random_index}.")
+            executor = concurrent.futures.ThreadPoolExecutor(max_workers=1)
+        return executor
+        # return self.executors.get(random_index)
 
     def process_esl_event(self, e):
         # print(json.loads(e.serialize('json')))