DataClient.wait_asset raises "Maximum number of attempts reached" when the last poll returns an active asset
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 82/100
調査の方向性
planet/clients/data.py のポーリングループを読み、issue によると試行回数を正しく数える OrdersClient.wait と比較してください。2 回目の応答のステータスが active となる max_attempts=2 のケースを再現し、上限エラーを発生させる前に最後に取得したステータスが確認されているか調べてください。最後の応答が active の場合はそれが返され、コールバックが active を受け取る一方、上限に達してもアセットが 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 はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
planetlabs/planet-client-python のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
planetlabs/planet-client-python#1230 ·
-
better-testing
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
planetlabs/planet-client-python#1110 ·
-
Broken examples in order_request and subscription_request docstrings, async SDK guide and CLI tipsオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 35/100
planetlabs/planet-client-python#1231 ·
-
FeaturesClient list_items does not support filtering対応中かも @steps-re が 105 日前に担当しました。 オープンproposal
難易度 3/5 1〜2日 初心者へのやさしさ 65/100
planetlabs/planet-client-python#1221 ·
-
FeaturesClient does not implement Update Feature対応中かも @tbarsballe が 134 日前に担当しました。 オープンproposal
難易度 3/5 1〜2日 初心者へのやさしさ 57/100
planetlabs/planet-client-python#1214 ·
planetlabs/planet-client-python の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
anchore/grype-db#1149 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[Bug]: `hermes plugins update` clones an entire monorepo twice - `subdir` is resolved but dropped at both catalog-update call sites対応中かも @HootRock が今日担当しました。 オープンcomp/cli P2 type/perf
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
NousResearch/hermes-agent#142417 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
SMC SPEC
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
tenstorrent/tt-oca-harness#3287 ·
メンテナーはふだん 1 日以内に返信
-
bug enhancement python
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
DewaldOosthuizen/tech-cheat-sheets-and-notes#392 ·
メンテナーはふだん 1 日以内に返信
-
security
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
fabriziosalmi/wildbox#801 ·
メンテナーはふだん 1 日以内に返信