robertoszek / pleroma-bot

Bot for mirroring one or multiple Twitter accounts in Pleroma/Mastodon/Misskey.
https://robertoszek.github.io/pleroma-bot
MIT License
103 stars 19 forks source link

Handle HTTP 429 error (rate limits) #42

Closed nemobis closed 3 years ago

nemobis commented 3 years ago
2021-04-26 12:58:17,140 pleroma_bot ERROR: Exception occurred
Traceback (most recent call last):
  File "/home/federico/git/federico/mastodon/lib64/python3.9/site-packages/pleroma_bot/cli.py", line 406, in main
    user.post_pleroma(
  File "/home/federico/git/federico/mastodon/lib64/python3.9/site-packages/pleroma_bot/_pleroma.py", line 153, in post_pleroma
    response.raise_for_status()
  File "/home/federico/git/federico/mastodon/lib64/python3.9/site-packages/requests/models.py", line 943, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 429 Client Error: Too Many Requests for url: https://mastodon.technology//api/v1/statuses

Maybe it's a good idea also to raise the wait from 0.5 seconds to 2 or something?

robertoszek commented 3 years ago

Hi! Good point, I experimented in the past with how much delay I could get away with and 0.5 seconds was a good middle ground for the instances I tested with. However, it's pretty obvious it's not ideal for everyone.

I think I will increase the default value to 2 seconds but also allow it to be overridden in the config file if the user wants to do so.

robertoszek commented 3 years ago

Hey, I added a mapping called delay_post which allows configuring how long the wait between submit requests is. By default is 0.5 seconds.

3f9eafd8b2849b55f23749fba965e62d50585eec