Skip to content

Commit

Permalink
Handle internal server error and sleep a bit #14 #9
Browse files Browse the repository at this point in the history
  • Loading branch information
yuletide committed Jan 5, 2023
1 parent 5d52cfb commit 9b28382
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion nitterbot/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from nitterbot.bot import init
from nitterbot.notifylistener import NotifyListener
from mastodon.errors import MastodonNetworkError
from mastodon.errors import MastodonInternalServerError
from time import sleep


def main():
Expand All @@ -18,7 +20,13 @@ def main():
mastodon.stream_user(listener)
except MastodonNetworkError as err:
print("Network error, reinitializing", err)
main() # this needs real refactoring to have proper retries forever, should we re-use the client or listener?
main() # this needs real refactoring to have proper retries forever,
# should we re-use the client or listener?
except MastodonInternalServerError as err:
print("Internal server error, what is going on?", err)
# Try giving it a breather
sleep(10)
main()


main()

0 comments on commit 9b28382

Please sign in to comment.