fix: adb 命令超时 + STF 释放失败检查,杜绝设备卡死/占用悬空
- adb 所有命令加 30s 超时:connect 到不可达地址不再无限挂起(worker 不再卡 connecting) - STF release 检查响应状态并重试:504 等失败不再被静默吞掉,释放失败会真实上报 - release_all_mine 返回 (released, failed);web /api/release 透出失败列表
This commit is contained in:
+9
-1
@@ -14,6 +14,9 @@ from core.logger import get_logger
|
||||
_log = get_logger("core.adb")
|
||||
|
||||
_ADB_LOCK = threading.Lock()
|
||||
# adb 命令超时(秒)。adb connect 到不可达主机(如 Tailscale IP 不通)会长时间挂起,
|
||||
# 没有超时会让 worker 永久卡在 connecting。connect/disconnect 正常都应瞬时完成。
|
||||
_ADB_TIMEOUT = 30
|
||||
|
||||
|
||||
def _adb(*args):
|
||||
@@ -21,8 +24,13 @@ def _adb(*args):
|
||||
|
||||
用 bytes 模式自己解码(Windows 下 subprocess text=True 会用 GBK 读 adb 输出,
|
||||
遇到非 GBK 字节会崩溃)。
|
||||
带 30s 超时:adb connect 到不可达地址可能挂很久,超时返回空串由调用方处理。
|
||||
"""
|
||||
r = subprocess.run([ADB_PATH, *args], capture_output=True)
|
||||
try:
|
||||
r = subprocess.run([ADB_PATH, *args], capture_output=True, timeout=_ADB_TIMEOUT)
|
||||
except subprocess.TimeoutExpired:
|
||||
_log.warning(f"adb {' '.join(args)} 超时 {_ADB_TIMEOUT}s")
|
||||
return ""
|
||||
out = (r.stdout or b"") + (r.stderr or b"")
|
||||
try:
|
||||
return out.decode("utf-8", errors="replace").strip()
|
||||
|
||||
Reference in New Issue
Block a user