Skip to content

Commit

Permalink
fix urllib3.util.retry.Retry import
Browse files Browse the repository at this point in the history
  • Loading branch information
ric-evans committed Aug 1, 2023
1 parent 8c0aa3e commit 569297c
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions rest_tools/client/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@
# fmt:off
# pylint: skip-file

from typing import Iterable
from typing import Collection

import requests
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry
from requests_futures.sessions import FuturesSession # type: ignore[import]
from urllib3.util.retry import Retry


def AsyncSession(
retries: int,
backoff_factor: float,
allowed_methods: Iterable[str] = ('HEAD', 'TRACE', 'GET', 'POST', 'PUT', 'OPTIONS', 'DELETE'),
status_forcelist: Iterable[int] = (408, 429, 500, 502, 503, 504),
allowed_methods: Collection[str] = ('HEAD', 'TRACE', 'GET', 'POST', 'PUT', 'OPTIONS', 'DELETE'),
status_forcelist: Collection[int] = (408, 429, 500, 502, 503, 504),
) -> FuturesSession:
"""Return a Session object with full retry capabilities.
Args:
retries (int): number of retries
backoff_factor (float): speed factor for retries (in seconds)
allowed_methods (iterable): http methods to retry on
status_forcelist (iterable): http status codes to retry on
allowed_methods (collection): http methods to retry on
status_forcelist (collection): http status codes to retry on
Returns:
:py:class:`requests.Session`: session object
Expand All @@ -51,16 +51,16 @@ def AsyncSession(
def Session(
retries: int,
backoff_factor: float,
allowed_methods: Iterable[str] = ('HEAD', 'TRACE', 'GET', 'POST', 'PUT', 'OPTIONS', 'DELETE'),
status_forcelist: Iterable[int] = (408, 429, 500, 502, 503, 504),
allowed_methods: Collection[str] = ('HEAD', 'TRACE', 'GET', 'POST', 'PUT', 'OPTIONS', 'DELETE'),
status_forcelist: Collection[int] = (408, 429, 500, 502, 503, 504),
) -> requests.Session:
"""Return a Session object with full retry capabilities.
Args:
retries (int): number of retries
backoff_factor (float): speed factor for retries (in seconds)
allowed_methods (iterable): http methods to retry on
status_forcelist (iterable): http status codes to retry on
allowed_methods (collection): http methods to retry on
status_forcelist (collection): http status codes to retry on
Returns:
:py:class:`requests.Session`: session object
Expand Down

0 comments on commit 569297c

Please sign in to comment.