修复掉视频的bug
This commit is contained in:
@@ -94,12 +94,20 @@ class ThreadManager:
|
||||
except Exception as e:
|
||||
LogManager.method_error(f"[{udid}] 设置停止事件失败: {e}", "task")
|
||||
|
||||
# 🔹 不阻塞主线程
|
||||
def _wait_stop():
|
||||
# 先给 1 秒高频检查机会(很多 I/O 点会在这个窗口立刻感知到)
|
||||
t0 = time.time()
|
||||
while time.time() - t0 < 1.0 and thread.is_alive():
|
||||
time.sleep(0.05)
|
||||
|
||||
# 再进入原有的 join 窗口
|
||||
thread.join(timeout=stop_timeout)
|
||||
if thread.is_alive():
|
||||
LogManager.method_info(f"[{udid}] 协作超时 -> 尝试强杀", "task")
|
||||
_async_raise(tid)
|
||||
try:
|
||||
_async_raise(tid) # 兜底:依然保留你的策略
|
||||
except Exception as e:
|
||||
LogManager.method_error(f"[{udid}] 强杀触发失败: {e}", "task")
|
||||
thread.join(timeout=kill_timeout)
|
||||
|
||||
if not thread.is_alive():
|
||||
@@ -136,10 +144,15 @@ class ThreadManager:
|
||||
with ThreadPoolExecutor(max_workers=4) as executor:
|
||||
futures = {executor.submit(cls.stop, udid): udid for udid in ids}
|
||||
for future in as_completed(futures):
|
||||
code, msg = future.result()
|
||||
udid = futures[future]
|
||||
try:
|
||||
code, msg = future.result()
|
||||
except Exception as e:
|
||||
LogManager.method_error(f"[{udid}] stop 调用异常: {e}", "task")
|
||||
failed.append(udid)
|
||||
continue
|
||||
if code != 200:
|
||||
failed.append(futures[future])
|
||||
|
||||
failed.append(udid)
|
||||
if failed:
|
||||
return 207, f"部分任务停止失败: {failed}"
|
||||
return 200, "全部停止请求已提交"
|
||||
Reference in New Issue
Block a user