fix: 采集商品页轮询避开慢速前台查询 (#115)
This commit is contained in:
@@ -815,6 +815,11 @@ class PddCollectService:
|
||||
if initial_app_state is not None
|
||||
else device.app_current()
|
||||
)
|
||||
package_hint = (
|
||||
PDD_PACKAGE_NAME
|
||||
if current.get("package") == PDD_PACKAGE_NAME
|
||||
else ""
|
||||
)
|
||||
before_open = self._read_page_observation(device, current)
|
||||
if current.get("package") != PDD_PACKAGE_NAME:
|
||||
stage = trace.stage("pdd_start_or_wait") if trace else nullcontext()
|
||||
@@ -849,7 +854,6 @@ class PddCollectService:
|
||||
last_recorded = ""
|
||||
while self._monotonic() < deadline:
|
||||
self._check_cancelled()
|
||||
current = device.app_current()
|
||||
if first_dump and trace is not None:
|
||||
with trace.stage("first_dump_hierarchy"):
|
||||
xml_data = self._dump_hierarchy(device)
|
||||
@@ -857,9 +861,9 @@ class PddCollectService:
|
||||
else:
|
||||
xml_data = self._dump_hierarchy(device)
|
||||
root = _parse_xml(xml_data)
|
||||
observation = classify_pdd_page(
|
||||
root, str(current.get("package") or "")
|
||||
)
|
||||
# 部分设备的 app_current() 一次会阻塞十秒以上,并错误报告
|
||||
# 设置页。循环中直接使用最新控件树,PDD 节点包名足以分类。
|
||||
observation = classify_pdd_page(root, package_hint)
|
||||
last_kind = observation.kind
|
||||
if trace is not None and last_kind != last_recorded:
|
||||
trace.record(
|
||||
|
||||
Reference in New Issue
Block a user