You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update rate limiting documentation to match implementation
- Fix incorrect default values in config example
- Add comprehensive exponential backoff example
- Update log message format to match actual output
- Add advanced usage section with datetime-based retry example
With example settings of 5 retries and no headers:
72
72
73
-
- First retry: Wait 30 seconds
74
-
- Second retry: Wait 60 seconds (30 * 2.0)
75
-
- Third retry: Wait 240 seconds (60 * 2.0²)
76
-
- Fourth retry: Wait 240 seconds (240 * 2.0²)
73
+
- First retry: Wait 60 seconds (base time)
74
+
- Second retry: Wait 90 seconds (60 * 1.5¹)
75
+
- Third retry: Wait 135 seconds (60 * 1.5²)
76
+
- Fourth retry: Wait 202.5 seconds (60 * 1.5³)
77
+
- Fifth retry: Wait 303.75 seconds (60 * 1.5⁴)
77
78
78
79
## Logging
79
80
@@ -93,7 +94,7 @@ client = FitbitClient(...)
93
94
You'll see log messages like:
94
95
95
96
```
96
-
WARNING:fitbit_client.SleepResource:Rate limit exceeded for get_sleep_log_list to sleep/list.json. [Rate Limit: 0/150, Reset in: 600s] (Will retry after 600 seconds if retries are enabled)
97
+
WARNING:fitbit_client.SleepResource:Rate limit exceeded for get_sleep_log_list to sleep/list.json. [Rate Limit: 0/150] Retrying in600 seconds. (4 retries remaining)
97
98
```
98
99
99
100
## Handling Unrecoverable Rate Limits
@@ -133,3 +134,27 @@ except RateLimitExceededException as e:
133
134
134
135
These can be used to implement more sophisticated retry or backoff strategies in
135
136
your application.
137
+
138
+
## Advanced Usage
139
+
140
+
You can implement custom strategies by combining rate limit information with
141
+
your own timing logic:
142
+
143
+
```python
144
+
from datetime import datetime, timedelta
145
+
from time import sleep
146
+
147
+
try:
148
+
client.get_daily_activity_summary(date="today")
149
+
except RateLimitExceededException as e:
150
+
# Calculate next reset time (typically the top of the next hour)
0 commit comments