Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9696936
D1659.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
D1659.diff
View Options
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
Details
Attached
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
Attached To
D1659: api/sync: allow to configure requests for pool size and retries
Event Timeline
Log In to Comment