|
@@ -95,13 +95,7 @@ class InboundClient:
|
|
self.start()
|
|
self.start()
|
|
else:
|
|
else:
|
|
# threading.Thread(target=self.process_esl_event, args=(e,)).start()
|
|
# 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):
|
|
def choose_thread_pool_executor(self, e):
|
|
call_id = EslEventUtil.getCallId(e)
|
|
call_id = EslEventUtil.getCallId(e)
|
|
@@ -113,7 +107,13 @@ class InboundClient:
|
|
else:
|
|
else:
|
|
random_index = random.randint(0, len(self.executors) - 1) if self.executors else 0
|
|
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)
|
|
# 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):
|
|
def process_esl_event(self, e):
|
|
# print(json.loads(e.serialize('json')))
|
|
# print(json.loads(e.serialize('json')))
|