homematicip.connection.buckets
Buckets
Class to manage the rate limiting of the HomematicIP Cloud API. The implementation is based on the token bucket algorithm.
__init__
__init__
take
async
take
tokens
async
tokens
Get the number of tokens in the bucket. Refill the bucket if necessary.
wait_and_take
async
wait_and_take
Wait until a token is available and then take it. Return True if successful, False otherwise.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
|
int
|
The maximum time to wait for a token in seconds. Default is 120 seconds. |
120
|
|
int
|
The number of tokens to take from the bucket. Default is 1. |
1
|
Returns:
Type | Description |
---|---|
bool
|
True if successful, False otherwise. |