跳到主要内容

browse_next

browse / browse_with_paging 返回的子节点超过服务端单页限制时, 服务端会返回非空的 continuation_point (续翻凭证). 用 browse_next 继续拿下一页.

前置阅读

签名

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

BrowsePage 字段

@dataclass
class BrowsePage:
references: List[Reference] = []
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)

否则服务端会在超时后 (典型 5 分钟) 自动 GC.


注意

  • continuation_point 是不透明 bytes, 不要修改 / 解析
  • 同一个 continuation_point 只能用一次
  • 服务端 ContinuationPoint 数量上限 (通常每 Session ~10-100), 超过后旧 CP 会被踢

下一步