Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

DataClient.wait_asset raises "Maximum number of attempts reached" when the last poll returns an active asset

未关闭 适合新手
#1,232 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

@auraseb 已经在做这个了。

开始于 2026年10月18日。

  • #1233 来自 @auraseb —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
82/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python
领域
api, backend

调研方向

阅读 planet/clients/data.py 中的轮询循环,并将其与 OrdersClient.wait 进行比较;issue 指出后者能正确处理尝试次数计数。复现 max_attempts=2 的情况,其中第二个响应的状态为 active,并检查在引发次数上限错误之前是否会检查最后获取的状态。完成标准是:返回最后一个 active 响应,且回调收到 active;如果 asset 达到上限时仍处于 inactive 状态,则引发错误。

由索引模型根据 Issue 内容生成。

描述

What happens

DataClient.wait_asset (and Planet().data.wait_asset and planet data asset-wait, which call it) fetches the asset on each attempt but only checks the status at the top of the next loop iteration. When the asset becomes active on the final allowed poll, the loop ends on the attempt count, the fresh status is never looked at, and a ClientError("Maximum number of attempts (N) reached.") is raised. The callback is also never called with active.

What should happen

If the last poll returns active, wait_asset should return that asset, the same as it does when activation finishes on any earlier poll. The error should only be raised when the asset is still not active after max_attempts polls.

Minimal repro

import asyncio, copy, httpx, respx
from planet import DataClient, Session, Auth

URL = "https://example.test/asset"
asset = {"_links": {"_self": URL}, "status": "activating"}
active = copy.deepcopy(asset)
active["status"] = "active"

@respx.mock
async def main():
    respx.get(URL).side_effect = [
        httpx.Response(200, json=asset),
        httpx.Response(200, json=active),
    ]
    async with Session(auth=Auth.from_key("x")) as sess:
        cl = DataClient(sess)
        print(await cl.wait_asset(asset, delay=0, max_attempts=2))

asyncio.run(main())

Output:

planet.exceptions.ClientError: Maximum number of attempts (2) reached.

The second and last poll returned "status": "active".

Root cause

In planet/clients/data.py, the loop condition is while not max_attempts or num_attempts < max_attempts, and the new asset is fetched at the bottom of the loop body after num_attempts += 1. When num_attempts reaches max_attempts the loop exits before the status check at the top runs, and the check after the loop only looks at num_attempts. OrdersClient.wait does not have this problem because it polls at the top of the loop and checks the state before counting the attempt.

主要语言
Python
星标
300
派生
100
PR 合并指标
30 天内没有已合并 PR

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

planetlabs/planet-client-python 的其他 Issue

查看 planetlabs/planet-client-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。