Page MenuHomeSoftware Heritage

D1659.diff
No OneTemporary

D1659.diff

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')

File Metadata

Mime Type
text/plain
Expires
Sun, Aug 17, 10:14 PM (1 w, 1 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3217538

Event Timeline