Skip to content

Commit

Permalink
Add Retry type hint to StacApiIO
Browse files Browse the repository at this point in the history
Add `Retry` type hint so that a retry object so that the `HTTPAdapter`s
are correctly mounted.
  • Loading branch information
rubenbaer committed Aug 18, 2023
1 parent 1454437 commit 54ddd0d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 1 addition & 2 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ If you'd like to configure this behavior, e.g. to retry on some ``50x`` response
retry = Retry(
total=5, backoff_factor=1, status_forcelist=[502, 503, 504], allowed_methods=None
)
stac_api_io = StacApiIO()
stac_api_io.session.mount("https://", HTTPAdapter(max_retries=retry))
stac_api_io = StacApiIO(max_retries=retry)
client = Client.open(
"https://planetarycomputer.microsoft.com/api/stac/v1", stac_io=stac_api_io
)
Expand Down
3 changes: 2 additions & 1 deletion pystac_client/stac_api_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from pystac.stac_io import DefaultStacIO
from requests import Request, Session
from requests.adapters import HTTPAdapter
from urllib3 import Retry

import pystac_client

Expand All @@ -49,7 +50,7 @@ def __init__(
parameters: Optional[Dict[str, Any]] = None,
request_modifier: Optional[Callable[[Request], Union[Request, None]]] = None,
timeout: Optional[Timeout] = None,
max_retries: Optional[int] = 5,
max_retries: Optional[Union[int, Retry]] = 5,
):
"""Initialize class for API IO
Expand Down

0 comments on commit 54ddd0d

Please sign in to comment.