Skip to content

Confusion over setting timeout and max_retries #791

Description

@scottyhq

The PlanetaryComputer API has been especially finicky for me today, giving the opportunity to try upping the default timeout and max_retries on a search. But these are not having a discernible effect.

It looks like timeout can be set either as a keyword to client.open() or as an input to StacApiIO(), could these be in conflict?

stac_io: StacApiIO | None = None,
timeout: Timeout | None = None,

timeout: Timeout | None = None,
max_retries: int | Retry | None = 5,

I was also expecting these two settings to work together (e.g. if we exceed a timeout, a retry will be triggered up to max_retries). But maybe retries are only attempted for specific return codes? Or maybe they only apply to client.search() and not subsequent commands like retrieving the item_collection?

Example:

import pystac_client 
from pystac_client.stac_api_io import StacApiIO
url = 'https://planetarycomputer.microsoft.com/api/stac/v1'
client = pystac_client.Client.open(
        url=url, stac_io=StacApiIO(max_retries=5), timeout=60,
)
%%time 

# This code occasionally fails with "APIError: The request exceeded the maximum allowed time, please try again. If the issue persists, please contact planetarycomputer@microsoft.com."

# fast
results = client.search(
    collections=["cop-dem-glo-30"],
    bbox=[-107.989298, 38.143321, -106.13571, 39.389549],
)  

# sporadic timeout at 30s
ic = results.item_collection() 

I came across this related over in pystac, but I'm still confused
stac-utils/pystac#1353

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions