DataClient.wait_asset raises "Maximum number of attempts reached" when the last poll returns an active asset
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 82/100
Línea de trabajo
Lee el bucle de sondeo en planet/clients/data.py y compáralo con OrdersClient.wait, que, según indica el issue, cuenta los intentos correctamente. Reproduce el caso con max_attempts=2, en el que la segunda respuesta tiene el estado active, e inspecciona si se comprueba el último estado obtenido antes de generar el error del límite. El trabajo estará listo cuando se devuelva la última respuesta activa y el callback reciba active, mientras que un asset que siga inactivo al alcanzar el límite genere el error.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Python
- Estrellas
- 300
- Forks
- 100
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de planetlabs/planet-client-python
-
CLI: invalid --geom/--geometry value prints a traceback and exits 1 instead of a usage errorAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
planetlabs/planet-client-python#1230 ·
-
better-testing
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
planetlabs/planet-client-python#1110 ·
-
Broken examples in order_request and subscription_request docstrings, async SDK guide and CLI tipsAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 35/100
planetlabs/planet-client-python#1231 ·
-
FeaturesClient list_items does not support filteringPosiblemente ocupada @steps-re la tomó hace 105 días. Abiertoproposal
Dificultad 3/5 1-2 días Aptitud para principiantes 65/100
planetlabs/planet-client-python#1221 ·
-
FeaturesClient does not implement Update FeaturePosiblemente ocupada @tbarsballe la tomó hace 134 días. Abiertoproposal
Dificultad 3/5 1-2 días Aptitud para principiantes 57/100
planetlabs/planet-client-python#1214 ·
Todos los issues de planetlabs/planet-client-python
Issues similares
-
[Bug] Unit tests reach real Bedrock call paths without patching the modelPosiblemente ocupada @proton0210 la tomó hoy. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
aws-samples/sample-aws-genai-db-modernizer#1318 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
pyarrow-25.0.1-cp310-cp310-manylinux_2_28_x86_64.whl: 1 vulnerabilities (highest severity is: 5.3)AbiertoMend: dependency security vulnerability
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
capitalone/locopy#394 ·
-
[Bug] Unhandled ValueError terminates watchdog thread when GISRC value contains multiple colonsAbiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
sdk-typescript: unquoted COPY globs in shell form are silently dropped from the image build contextAbiertobug javascript
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
ietf-tools/datatracker#11922 · 1 comentario ·
Los mantenedores suelen responder en 1 día