diff --git a/sentinelhub/download/rate_limit.py b/sentinelhub/download/rate_limit.py index aec22a0a..acab4dc6 100644 --- a/sentinelhub/download/rate_limit.py +++ b/sentinelhub/download/rate_limit.py @@ -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 diff --git a/sentinelhub/download/sentinelhub_client.py b/sentinelhub/download/sentinelhub_client.py index 8b1f455a..93fa267b 100644 --- a/sentinelhub/download/sentinelhub_client.py +++ b/sentinelhub/download/sentinelhub_client.py @@ -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) @@ -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