|
@@ -583,19 +583,17 @@ class BotAgent:
|
|
|
registry.BOT_AGENT_LIVES.set(self.user_part_pool.qsize())
|
|
|
self.ep.libHandleEvents(100)
|
|
|
|
|
|
- try:
|
|
|
- self.logger.info("create pjsua will shutdown 1111")
|
|
|
- self.call_players.clear()
|
|
|
- self.logger.info("create pjsua will shutdown 2222")
|
|
|
- self.accounts.clear()
|
|
|
- self.logger.info("create pjsua will shutdown 3333")
|
|
|
- self.calls.clear()
|
|
|
- self.logger.info("create pjsua will shutdown 4444")
|
|
|
- # Destroy the library
|
|
|
- self.ep.libDestroy()
|
|
|
- self.logger.info("create pjsua already shutdown")
|
|
|
- except:
|
|
|
- traceback.print_exc()
|
|
|
+ self.logger.info("create pjsua will shutdown 1111")
|
|
|
+ self.call_players.clear()
|
|
|
+ self.logger.info("create pjsua will shutdown 2222")
|
|
|
+ self.accounts.clear()
|
|
|
+ self.logger.info("create pjsua will shutdown 3333")
|
|
|
+ self.calls.clear()
|
|
|
+ self.logger.info("create pjsua will shutdown 4444")
|
|
|
+ # Destroy the library
|
|
|
+ self.ep.libDestroy()
|
|
|
+ self.logger.info("create pjsua already shutdown")
|
|
|
+
|
|
|
|
|
|
def main_thread_daemon(self):
|
|
|
while not self.daemon_stopping:
|
|
@@ -741,15 +739,15 @@ class BotAgent:
|
|
|
time.sleep(1)
|
|
|
self.logger.info("destroy, come in 33333")
|
|
|
|
|
|
- # if not self.pjsua_thread.is_alive():
|
|
|
- # self.logger.info("destroy, pre thread already stopped")
|
|
|
- # return
|
|
|
- # ident = self.pjsua_thread.ident
|
|
|
- # thread_id = ctypes.pythonapi.PyThreadState_SetAsyncExc
|
|
|
- # res = ctypes.pythonapi.PyThreadState_SetAsyncExc(
|
|
|
- # ctypes.c_long(ident), ctypes.py_object(SystemExit)
|
|
|
- # )
|
|
|
- # self.logger.info("destroy, ident=%s, thread_id=%s, res=%s", ident, thread_id, res)
|
|
|
+ if not self.pjsua_thread.is_alive():
|
|
|
+ self.logger.info("destroy, pre thread already stopped")
|
|
|
+ return
|
|
|
+ ident = self.pjsua_thread.ident
|
|
|
+ thread_id = ctypes.pythonapi.PyThreadState_SetAsyncExc
|
|
|
+ res = ctypes.pythonapi.PyThreadState_SetAsyncExc(
|
|
|
+ ctypes.c_long(ident), ctypes.py_object(SystemExit)
|
|
|
+ )
|
|
|
+ self.logger.info("destroy, ident=%s, thread_id=%s, res=%s", ident, thread_id, res)
|
|
|
# if res == 0:
|
|
|
# raise ValueError("Invalid thread ID")
|
|
|
# elif res > 1:
|