DataClient.wait_asset raises "Maximum number of attempts reached" when the last poll returns an active asset
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 82/100
Hướng nghiên cứu
Đọc vòng lặp polling trong planet/clients/data.py và so sánh với OrdersClient.wait, nơi issue cho biết xử lý đúng việc đếm số lần thử. Tái hiện trường hợp với max_attempts=2, trong đó phản hồi thứ hai có trạng thái active, và kiểm tra xem trạng thái được lấy cuối cùng có được kiểm tra trước khi phát sinh lỗi giới hạn hay không. Hoàn tất khi phản hồi active cuối cùng được trả về và callback nhận active, còn một asset vẫn inactive khi chạm giới hạn thì phát sinh lỗi.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Python
- Star
- 300
- Fork
- 100
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của planetlabs/planet-client-python
-
CLI: invalid --geom/--geometry value prints a traceback and exits 1 instead of a usage errorĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
planetlabs/planet-client-python#1230 ·
-
better-testing
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
planetlabs/planet-client-python#1110 ·
-
Broken examples in order_request and subscription_request docstrings, async SDK guide and CLI tipsĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
planetlabs/planet-client-python#1231 ·
-
FeaturesClient list_items does not support filteringCó thể đã có người làm @steps-re đã nhận 105 ngày trước. Đang mởproposal
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 65/100
planetlabs/planet-client-python#1221 ·
-
FeaturesClient does not implement Update FeatureCó thể đã có người làm @tbarsballe đã nhận 133 ngày trước. Đang mởproposal
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 57/100
planetlabs/planet-client-python#1214 ·
Tất cả issue của planetlabs/planet-client-python
Issue tương tự
-
bug documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
awslabs/visual-asset-management-system#514 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
backend bug spec:REQ-053
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
nolte/kamerplanter#2547 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
EleutherAI/lm-evaluation-harness#4425 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Gemini: respect PLANNING_DISABLED=1 in lifecycle context hooksCó thể đã có người làm @AmariAugustin đã nhận hôm nay. Đang mởbug good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 87/100
OthmanAdi/planning-with-files#329 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
wr.dynamodb.read_items returns [{}] for a single partition value that does not existCó thể đã có người làm @auraseb đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
aws/aws-sdk-pandas#3520 ·
Maintainer thường phản hồi trong vòng 2 ngày