Merge pull request #172 from codl/avoid-limit

mastodon: stop before hitting the rate limit
This commit is contained in:
codl 2019-03-11 16:40:33 +01:00 committed by GitHub
commit 41683fcffd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -1,6 +1,8 @@
## next
* internals: make fetch_acc unique
* back off before hitting rate limit on mastodon instances
* fix: fetch\_acc running multiple copies fetching the same posts
* internals: increased frequency of refresh jobs, decreased frequency of bookkeeping jobs
## v1.4.3

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: