Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

graceful retry at firehose streaming error #1

Open
Nick-the-freak opened this issue Oct 29, 2024 · 0 comments
Open

graceful retry at firehose streaming error #1

Nick-the-freak opened this issue Oct 29, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@Nick-the-freak
Copy link
Member

Current code attempts to reconnect/re-stream from the instance whenever an error occurs. Though there's 10 seconds between each retry, it should increase the wait time dynamically(til 1/day) when error keeps happening to avoid putting too much pressure on the instance's server.

From observation, 502 Bad Gateway and Unauthorized are the most frequent cases whenever an error, probably update the check_failed_tokens.sh script to only report when Unauthorized error occurs.

def start_streaming(server_info):
while True:
try:
mastodon = Mastodon(
access_token=server_info['access_token'],
api_base_url=server_info['api_base_url']
)
listener = MyStreamListener(server_info['api_base_url'])
logging.info(f"Listening to {server_info['api_base_url']}")
# Stream federated public timeline
mastodon.stream_public(listener)
# # Stream local public timeline
# mastodon.stream_local(listener)
except Exception as e:
logging.error(f"Error in streaming from {server_info['api_base_url']}: {e}")
sleep(10) # Wait for 10 seconds before trying to reconnect

@Nick-the-freak Nick-the-freak added the enhancement New feature or request label Oct 29, 2024
@Nick-the-freak Nick-the-freak self-assigned this Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant