Skip to content

Commit

Permalink
Add fixes to release of 3.9.4, Merge pull request #508 from sentinel-…
Browse files Browse the repository at this point in the history
…hub/develop

Add fixes to release of 3.9.4
  • Loading branch information
zigaLuksic authored Dec 7, 2023
2 parents e0e6bb5 + 9ba4fe0 commit 34193fd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 6 additions & 1 deletion sentinelhub/download/rate_limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ def register_next(self) -> float:
return wait_time

def update(self, headers: dict, *, default: float) -> None:
"""Update the next possible download time if the service has responded with the rate limit"""
"""Update the next possible download time if the service has responded with the rate limit.
:param headers: The headers that (may) contain information about waiting times.
:param default: The default waiting time (in milliseconds) when retrying after getting a
TOO_MANY_REQUESTS response without appropriate retry headers.
"""
retry_after: float = int(headers.get(self.RETRY_HEADER, default)) # can be a string representation of a number
retry_after = retry_after / 1000

Expand Down
6 changes: 3 additions & 3 deletions sentinelhub/download/sentinelhub_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ def __init__(self, *, session: SentinelHubSession | None = None, default_retry_t
:param session: If a session object is provided here then this client instance will always use only the
provided session. Otherwise, it will either use a cached session or create a new session and cache
it.
:param default_retry_time: The default waiting time when retrying after getting a TOO_MANY_REQUESTS response
without appropriate retry headers.
:param default_retry_time: The default waiting time (in seconds) when retrying after getting a TOO_MANY_REQUESTS
response without appropriate retry headers.
:param kwargs: Optional parameters from DownloadClient
"""
super().__init__(**kwargs)
Expand All @@ -51,7 +51,7 @@ def __init__(self, *, session: SentinelHubSession | None = None, default_retry_t
f"{session} was given"
)
self.session = session
self.default_retry_time = default_retry_time
self.default_retry_time = default_retry_time * 1000 # rescale to milliseconds

self.rate_limit = SentinelHubRateLimit(num_processes=self.config.number_of_download_processes)
self.lock: Lock | None = None
Expand Down

0 comments on commit 34193fd

Please sign in to comment.