Skip to content

Configure automatic retry of failed connections #254

Open
@joachimBurket

Description

@joachimBurket

We have occasionally connection errors with our internal proxy, and could benefit to set the automatic retry of requests's Session (https://requests.readthedocs.io/en/latest/user/advanced/#example-automatic-retries).

Would you be open to add the automatic retry on the request's Session?

# cert_manager/client.py

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

...

class Client:

    def __init__(self, **kwargs):
        ...

        self.__session = requests.Session()

        retries = Retry(
            total=3,
            backoff_factor=0.1,
            allowed_methods={"HEAD", "GET", "POST", "PUT", "PATCH", "DELETE"},
        )
        self.__session.mount('https://', HTTPAdapter(max_retries=retries))

Or eventually to allowing to pass a Session object during the Client creation?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions