bear / python-twitter

A Python wrapper around the Twitter API.
Apache License 2.0
3.41k stars 955 forks source link

sleep_on_rate_limit still returning exception? #625

Closed aaronn closed 4 years ago

aaronn commented 4 years ago

I'm using the sleep_on_rate_limit flag and it's generally working but very rarely for some reason in my logs I'm still seeing a failed error come through with [{'message': 'Rate limit exceeded', 'code': 88}].

Any reason why this might happen, and any way I can get it to still continue the scheduled work and just go back to sleep? I could try / catch the Exception but it would just skip the loop of scheduled work right? (FWIW I'm looping through results returned from getFollowerID then UsersLookup.

aaronn commented 4 years ago

OK, I believe this is because I'm actually hitting the rate limit on the CheckRateLimit endpoint. Since the UsersLookup endpoint in theory has a higher limit than this endpoint, and CheckRateLimit is called each time– there is no way to complete a full UsersLookup query which is a maximum of 900 requests per window because CheckRateLimit is called every time with a maximum of 180 requests per window.

aaronn commented 4 years ago

I think this is my own idiocy. CheckRateLimit doesn’t hit the endpoint— only on init.