ソースを参照

事件队列机制修复

刘威 6 ヶ月 前
コミット
39df8bc67b

+ 1 - 1
src/core/callcenter/call.py

@@ -34,7 +34,7 @@ class CallService:
     def hangup(self, request: HangupCallRequest):
         pass
 
-    def hangup_all(self, call_info: CallInfo, caseEnum: CallCauseEnum):
+    def hangup_all(self, call_info: CallInfo, case_enum: CallCauseEnum):
         pass
 
     def hangup_by_call_id(self, call_id):

+ 2 - 10
src/core/callcenter/esl/client.py

@@ -78,9 +78,7 @@ class InboundClient:
                     time.sleep(3)
                     self.start()
                 else:
-                    threading.Thread(target=self.process_esl_event, args=(e, )).start()
-                    # TODO thread pool is shutdown, waiting fix
-                    #threading.Thread(target=self.submit_thread_pool_executor, args=(e, )).start()
+                    self.choose_thread_pool_executor(e).submit(self.process_esl_event, e)
 
     def choose_thread_pool_executor(self, e):
         call_id = EslEventUtil.getCallId(e)
@@ -91,15 +89,9 @@ class InboundClient:
             random_index = abs(mmh3.hash(random_id)) % len(self.executors)
         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)
 
-    def submit_thread_pool_executor(self, e):
-        executor = self.choose_thread_pool_executor(e)
-        future = executor.submit(self.process_esl_event, e)
-        for future in concurrent.futures.as_completed(future):
-            future.result()
-            print('complete')
-
     def process_esl_event(self, e):
         # print(json.loads(e.serialize('json')))
         event_name = EslEventUtil.getEventName(e)

+ 3 - 1
src/core/callcenter/esl/handler/default_esl_event_handler.py

@@ -2,6 +2,7 @@
 # encoding:utf-8
 
 import json
+import threading
 from src.core.callcenter.esl.handler.esl_event_handler import EslEventHandler
 
 
@@ -11,4 +12,5 @@ class DefaultEslEventHandler(EslEventHandler):
         super().__init__(inbound)
 
     def handle(self, address, event, coreUUID):
-        print('default event handle, msg=', json.loads(event.serialize('json')))
+        print('default event handle,', threading.currentThread().name, json.loads(event.serialize('json')))
+