barissozudogru's picture
bundle research_papers_mcp source, drop git+install
57272d3 verified
Raw
History Blame Contribute Delete
708 Bytes
"""Shared HTTP session with retry + exponential backoff.
All concrete sources share this session so 429/5xx retries, timeouts,
and TLS reuse are uniform. The private `_http` name is also exposed
from the sources package for tests that introspect retry config.
"""
import requests
from requests.adapters import HTTPAdapter
from urllib3.util import Retry
_retry_strategy = Retry(
total=3,
backoff_factor=0.5, # 0.5s, 1s, 2s
status_forcelist=[429, 500, 502, 503, 504],
allowed_methods=["GET", "POST"],
raise_on_status=False,
)
_http = requests.Session()
_http.mount("https://", HTTPAdapter(max_retries=_retry_strategy))
_http.mount("http://", HTTPAdapter(max_retries=_retry_strategy))