diff --git a/pyvulnerabilitylookup/api.py b/pyvulnerabilitylookup/api.py index 9a35b60..bd8ac19 100644 --- a/pyvulnerabilitylookup/api.py +++ b/pyvulnerabilitylookup/api.py @@ -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'''