跳到主要内容

browse_next

当节点子数超过服务端单页限制 (底层一次请求最多 1000 条) 时, 服务端在 BrowseResult 里给非空的 continuation_point (续翻凭证). 用 browse_next 继续拿下一页.

前置阅读
  • 想拿到 continuation_point 必须用 browse_with_paging, 普通 browse 会丢弃 CP (只取 References, 不读续翻凭证).

签名​

def browse_next(self,
continuation_point: Optional[bytes],
release: bool = False) -> BrowsePage: ...
参数说明
continuation_point上一次 browse_with_paging / browse_next 返回的续翻凭证 (bytes)
releaseTrue = 放弃续翻, 服务端释放资源 (不返回 references)

BrowsePage 字段​

@dataclass
class BrowsePage:
references: List[Reference] # 默认 None, 构造后变成 []
continuation_point: Optional[bytes] = None # None 表示无更多页

完整翻页例子​

page = ua.browse_with_paging("ns=2;s=BigFolder")
all_refs = list(page.references)

while page.continuation_point is not None:
page = ua.browse_next(page.continuation_point)
all_refs.extend(page.references)

print(f"Total {len(all_refs)} children")

主动释放 (节省服务端资源)​

服务端为每个 ContinuationPoint 维护状态, 占用资源. 如果中途不想继续翻, 调 release=True 显式释放:

ua.browse_next(page.continuation_point, release=True)

release 模式下服务端只释放、不再给 references, 所以拿到的 BrowsePage.references 是空列表, continuation_point 是 None。SDK 不知道服务端多久回收没释放的 CP —— 那是服务端的事, 想确定地归还资源就显式 release=True。

注意​

  • continuation_point 是不透明 bytes, 不要修改 / 解析
  • 翻页请始终用最近一次 browse_next 返回的 continuation_point 继续 (每翻一页服务端给的是新的 CP)
  • CP 的数量上限和回收时机由服务端决定, SDK 侧只做透传

下一步​