new: Auto retry on HTTP requests
Some checks failed
Python application - MyPy / Python 3.12 sample (push) Has been cancelled
Python application - MyPy / Python 3.13 sample (push) Has been cancelled
Python application - MyPy / Python 3.10 sample (push) Has been cancelled
Python application - MyPy / Python 3.11 sample (push) Has been cancelled
Python application - Test Public Interface / Python 3.10 sample (push) Has been cancelled
Python application - Test Public Interface / Python 3.11 sample (push) Has been cancelled
Python application - Test Public Interface / Python 3.12 sample (push) Has been cancelled
Python application - Test Public Interface / Python 3.13 sample (push) Has been cancelled

This commit is contained in:
Raphaël Vinot 2024-11-24 01:57:38 +01:00
parent bd1684e2c3
commit 46b322ff43

View file

@ -13,6 +13,9 @@ from urllib.parse import urljoin, urlparse
import requests
from urllib3.util import Retry
from requests.adapters import HTTPAdapter
def enable_full_debug() -> None:
import http.client as http_client
@ -47,7 +50,8 @@ class PyVulnerabilityLookup():
self.session.headers['Content-Type'] = 'application/json'
if proxies:
self.session.proxies.update(proxies)
self.session.request = functools.partial(self.session.request, timeout=10)
retries = Retry(total=5, backoff_factor=1, status_forcelist=[500, 502, 503, 504])
self.session.mount('https://', HTTPAdapter(max_retries=retries))
def set_apikey(self, apikey: str) -> None:
'''Set the API key to use for the requests'''