Use default values in the util/req module (#149)
So users can change them. Fixes #147
This commit is contained in:
Родитель
7e81abe91b
Коммит
aa2790a592
|
@ -4,12 +4,21 @@ from functools import lru_cache
|
|||
import requests
|
||||
from requests.packages.urllib3.util.retry import Retry
|
||||
|
||||
# https://urllib3.readthedocs.io/en/latest/reference/urllib3.util.html#module-urllib3.util.retry
|
||||
DEFAULT_RETRIES = 5
|
||||
DEFAULT_BACKOFF_FACTOR = 0.1
|
||||
DEFAULT_STATUS_FORCELIST = [500, 502, 503, 504]
|
||||
|
||||
|
||||
@lru_cache(maxsize=None)
|
||||
def get_session(name, concurrency=50):
|
||||
session = requests.Session()
|
||||
|
||||
retry = Retry(total=5, backoff_factor=0.1, status_forcelist=[500, 502, 503, 504])
|
||||
retry = Retry(
|
||||
total=DEFAULT_RETRIES,
|
||||
backoff_factor=DEFAULT_BACKOFF_FACTOR,
|
||||
status_forcelist=DEFAULT_STATUS_FORCELIST,
|
||||
)
|
||||
|
||||
# Default HTTPAdapter uses 10 connections. Mount custom adapter to increase
|
||||
# that limit. Connections are established as needed, so using a large value
|
||||
|
|
Загрузка…
Ссылка в новой задаче