增加切换账号功能
This commit is contained in:
@@ -20,6 +20,7 @@ class ThreadManager:
|
||||
@classmethod
|
||||
def add(cls, udid: str, thread: threading.Thread, event: threading.Event) -> Tuple[int, str]:
|
||||
LogManager.method_info(f"准备创建任务:{udid}", "task")
|
||||
LogManager.method_info("创建线程成功","监控消息")
|
||||
with cls._lock:
|
||||
# 判断当前设备是否有任务
|
||||
if cls._tasks.get(udid, None) is not None:
|
||||
@@ -61,13 +62,19 @@ class ThreadManager:
|
||||
@classmethod
|
||||
def _kill_thread(cls, tid: int) -> bool:
|
||||
"""向原生线程 ID 抛 KeyboardInterrupt,强制跳出"""
|
||||
res = ctypes.pythonapi.PyThreadState_SetAsyncExc(ctypes.c_long(tid),
|
||||
ctypes.py_object(KeyboardInterrupt))
|
||||
if res == 0: # 线程已不存在
|
||||
print("线程不存在")
|
||||
return False
|
||||
if res > 1: # 命中多个线程,重置
|
||||
print("命中了多个线程")
|
||||
ctypes.pythonapi.PyThreadState_SetAsyncExc(ctypes.c_long(tid), 0)
|
||||
print("杀死线程成功")
|
||||
return True
|
||||
try:
|
||||
res = ctypes.pythonapi.PyThreadState_SetAsyncExc(ctypes.c_long(tid),
|
||||
ctypes.py_object(KeyboardInterrupt))
|
||||
# LogManager.method_info(f"向原生线程 {tid} 抛 KeyboardInterrupt,强制跳出", "task")
|
||||
if res == 0: # 线程已不存在
|
||||
print("线程不存在")
|
||||
return False
|
||||
if res > 1: # 命中多个线程,重置
|
||||
print("命中了多个线程")
|
||||
ctypes.pythonapi.PyThreadState_SetAsyncExc(ctypes.c_long(tid), 0)
|
||||
LogManager.method_info("杀死线程创建成功", "监控消息")
|
||||
|
||||
print("杀死线程成功")
|
||||
return True
|
||||
except Exception as e:
|
||||
print("杀死线程出现问题 错误的原因:",e)
|
||||
Reference in New Issue
Block a user