mastodon: stop before hitting the rate limit

This commit is contained in:
codl 2019-03-11 12:26:25 +01:00
parent 689c013f55
commit a68a673925
No known key found for this signature in database
GPG Key ID: 6CD7C8891ED1233A
1 changed files with 2 additions and 0 deletions

View File

@ -87,6 +87,8 @@ def get_api_for_acc(account):
# https://github.com/tootsuite/mastodon/issues/4637
# so we have to do this:
api.timeline()
if api.ratelimit_remaining / api.ratelimit_limit < 1/4:
raise TemporaryError("Rate limit too low")
return api
except MastodonUnauthorizedError as e:
if sentry: