增加健壮度。修复wda无法启动的bug。
This commit is contained in:
@@ -147,13 +147,15 @@ class Deviceinfo(object):
|
||||
if new_udids:
|
||||
futures = {self._connect_pool.submit(self._connect_device_task, udid): udid
|
||||
for udid in new_udids}
|
||||
for f in as_completed(futures, timeout=10):
|
||||
udid = futures[f]
|
||||
try:
|
||||
f.result(timeout=8) # 单台 8 s 硬截止
|
||||
except Exception as e:
|
||||
LogManager.error(f"连接任务超时/失败: {e}", udid)
|
||||
|
||||
try:
|
||||
for f in as_completed(futures, timeout=30):
|
||||
udid = futures[f]
|
||||
try:
|
||||
f.result(timeout=8)
|
||||
except Exception as e:
|
||||
LogManager.error(text=f"连接任务失败:{e}", udid=udid)
|
||||
except TimeoutError:
|
||||
LogManager.warning(text="部分设备连接超时,已跳过")
|
||||
time.sleep(1)
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
@@ -313,6 +315,12 @@ class Deviceinfo(object):
|
||||
self._port_in_use.remove(port)
|
||||
self._port_pool.append(port)
|
||||
|
||||
# 检测usb是否超时
|
||||
def _usb_client_with_timeout(self,udid: str, timeout: 8):
|
||||
with ThreadPoolExecutor(max_workers=1) as exe:
|
||||
fut = exe.submit(wda.USBClient, udid, 8100)
|
||||
return fut.result(timeout=timeout)
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# 线程池里真正干活的地方(原 connectDevice 逻辑搬过来)
|
||||
# ------------------------------------------------------------------
|
||||
@@ -320,6 +328,12 @@ class Deviceinfo(object):
|
||||
if not self.is_device_trusted(udid):
|
||||
LogManager.warning("设备未信任,跳过 WDA 启动", udid)
|
||||
return
|
||||
|
||||
d = self._usb_client_with_timeout(udid, 8) # 8 秒必返
|
||||
if d is None:
|
||||
LogManager.info(f"设备链接超时,{udid}")
|
||||
return
|
||||
|
||||
try:
|
||||
d = wda.USBClient(udid, 8100)
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user