Skip to content

Conversation

@m-aciek
Copy link
Collaborator

@m-aciek m-aciek commented Feb 4, 2025

Better version of #51.


📚 Documentation preview 📚: https://pydocs-translation-dashboard--52.org.readthedocs.build/

@m-aciek m-aciek marked this pull request as ready for review February 4, 2025 23:13
Copy link

@willingc willingc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Member

@mattwang44 mattwang44 Feb 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that backoff is not actively maintained (ref). The retry mechanism from urllib3 (which has exponential backoff too) could be a good alternative.

from requests.adapters import HTTPAdapter
from requests.sessions import Session
from urllib3.util import Retry

def make_session():
    session = Session()
    retry = Retry(
        total=5,
        backoff_factor=1,
        allowed_methods=None,  # all methods are allowed
        status_forcelist={502, 503, 504},  # add the status code of Plausible error response here
    )
    session.mount('https://', HTTPAdapter(max_retries=retry))
    return session

session = make_session()
session.get(..., timeout=40)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please note that BadZipFile is raised later, after successfully receiving the request. Hm, or not, actually I now realized we don't check the response status code. Let me investigate and try with urllib3.Retry 👍

@m-aciek m-aciek marked this pull request as draft February 5, 2025 06:04
@m-aciek m-aciek closed this Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants