Merge pull request #10016 from froggleston/feat/clients

Add support for requests pool size configuration
This commit is contained in:
Matthias 2024-03-29 16:09:56 +01:00 committed by GitHub
commit 95fe0d5d82
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -21,10 +21,19 @@ logger = logging.getLogger("ft_rest_client")
class FtRestClient: class FtRestClient:
def __init__(self, serverurl, username=None, password=None): def __init__(self, serverurl, username=None, password=None,
pool_connections=10, pool_maxsize=10):
self._serverurl = serverurl self._serverurl = serverurl
self._session = requests.Session() self._session = requests.Session()
# allow configuration of pool
adapter = requests.adapters.HTTPAdapter(
pool_connections=pool_connections,
pool_maxsize=pool_maxsize
)
self._session.mount('http://', adapter)
self._session.auth = (username, password) self._session.auth = (username, password)
def _call(self, method, apipath, params: Optional[dict] = None, data=None, files=None): def _call(self, method, apipath, params: Optional[dict] = None, data=None, files=None):