sentinelhub.download.rate_limit
Module implementing rate limiting logic for Sentinel Hub service
- class sentinelhub.download.rate_limit.PolicyType(value)[source]
Bases:
Enum
Enum defining different types of policies
- PROCESSING_UNITS = 'PROCESSING_UNITS'
- REQUESTS = 'REQUESTS'
- class sentinelhub.download.rate_limit.SentinelHubRateLimit(num_processes=1, minimum_wait_time=0.05, maximum_wait_time=60.0)[source]
Bases:
object
Class implementing rate limiting logic of Sentinel Hub service
It has 2 public methods:
register_next - tells if next download can start or if not, what is the wait before it can be asked again
update - updates expectations according to headers obtained from download
The rate limiting object is collecting information about the status of rate limiting policy buckets from Sentinel Hub service. According to this information and a feedback from download requests it adapts expectations about when the next download attempt will be possible.
- Parameters:
- RETRY_HEADER = 'Retry-After'
- UNITS_SPENT_HEADER = 'X-ProcessingUnits-Spent'
- class sentinelhub.download.rate_limit.PolicyBucket(policy_type, policy_payload)[source]
Bases:
object
A class representing Sentinel Hub policy bucket
- Parameters:
policy_type (PolicyType) – A type of policy
policy_payload (Dict[str, Any]) – A dictionary of policy parameters
- count_cost_per_second(elapsed_time, new_content)[source]
Calculates the cost per second for the bucket given the elapsed time and the new content.
In the calculation it assumes that during the elapsed time bucket was being filled all the time - i.e. it assumes the bucket has never been full for a non-zero amount of time in the elapsed time period.