fix(vaults): size the HTTP vault connection pool for parallel lookups

This commit is contained in:
imSp4rky
2026-10-15 16:16:05 -06:00
parent 89f433963a
commit fae0f97102
2 changed files with 10 additions and 0 deletions
+5
View File
@@ -2,8 +2,10 @@ from typing import Iterator, Optional, Union
from uuid import UUID from uuid import UUID
from requests import Response, Session from requests import Response, Session
from requests.adapters import HTTPAdapter
from unshackle.core import __version__ from unshackle.core import __version__
from unshackle.core.session import POOL_MAX_SIZE
from unshackle.core.vault import Vault from unshackle.core.vault import Vault
@@ -23,6 +25,9 @@ class API(Vault):
self.uri = uri.rstrip("/") self.uri = uri.rstrip("/")
self.timeout = timeout self.timeout = timeout
self.session = Session() self.session = Session()
adapter = HTTPAdapter(pool_connections=POOL_MAX_SIZE, pool_maxsize=POOL_MAX_SIZE)
self.session.mount("https://", adapter)
self.session.mount("http://", adapter)
self.session.headers.update({"User-Agent": f"unshackle v{__version__}"}) self.session.headers.update({"User-Agent": f"unshackle v{__version__}"})
self.session.headers.update({"Authorization": f"Bearer {token}"}) self.session.headers.update({"Authorization": f"Bearer {token}"})
+5
View File
@@ -4,8 +4,10 @@ from typing import Iterator, Optional, Union
from uuid import UUID from uuid import UUID
from requests import Session from requests import Session
from requests.adapters import HTTPAdapter
from unshackle.core import __version__ from unshackle.core import __version__
from unshackle.core.session import POOL_MAX_SIZE
from unshackle.core.vault import Vault from unshackle.core.vault import Vault
@@ -60,6 +62,9 @@ class HTTP(Vault):
self.batch_insert = True self.batch_insert = True
self.current_title = None self.current_title = None
self.session = Session() self.session = Session()
adapter = HTTPAdapter(pool_connections=POOL_MAX_SIZE, pool_maxsize=POOL_MAX_SIZE)
self.session.mount("https://", adapter)
self.session.mount("http://", adapter)
self.session.headers.update({"User-Agent": f"unshackle v{__version__}"}) self.session.headers.update({"User-Agent": f"unshackle v{__version__}"})
self.api_session_id = None self.api_session_id = None