diff --git a/swh/core/api/__init__.py b/swh/core/api/__init__.py --- a/swh/core/api/__init__.py +++ b/swh/core/api/__init__.py @@ -159,6 +159,12 @@ base_url = url if url.endswith('/') else url + '/' self.url = base_url self.session = requests.Session() + adapter = requests.adapters.HTTPAdapter( + max_retries=kwargs.get('max_retries', 3), + pool_connections=kwargs.get('pool_connections', 20), + pool_maxsize=kwargs.get('pool_maxsize', 100)) + self.session.mount(self.url, adapter) + self.timeout = timeout self.chunk_size = chunk_size diff --git a/swh/core/api/tests/test_api.py b/swh/core/api/tests/test_api.py --- a/swh/core/api/tests/test_api.py +++ b/swh/core/api/tests/test_api.py @@ -72,7 +72,10 @@ def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - self.session.mount('mock', adapter) + # we need to mount the mock adapter on the base url to override + # SWHRemoteAPI's mechanism that also mounts an HTTPAdapter + # (for configuration purpose) + self.session.mount('mock://example.com/', adapter) c = Testclient(url='mock://example.com/') res = c.test_endpoint('spam')