Skip to content

Commit b502574

Browse files
authored
Merge pull request #210 from Nath-B/set-optional-session-arguments-maxretries-poolsizes
Setting optional arguments such as : max retries, pool-connections, pool maxsize
2 parents 001c9cf + 0c7b78e commit b502574

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/vonage/_internal.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import logging
22

3+
from requests.adapters import HTTPAdapter
34
from requests.sessions import Session
45

56
from .errors import AuthenticationError, ClientError, ServerError
@@ -13,10 +14,13 @@
1314

1415

1516
class BasicAuthenticatedServer(object):
16-
def __init__(self, host, user_agent, api_key, api_secret, timeout=None):
17+
def __init__(self, host, user_agent, api_key, api_secret, timeout=None, pool_connections=10, pool_maxsize=10, max_retries=3):
1718
self._host = host
1819
self._session = session = Session()
1920
self.timeout = None
21+
adapter = HTTPAdapter(pool_connections=pool_connections, pool_maxsize=pool_maxsize, max_retries=max_retries)
22+
self._session.mount("https://", adapter)
23+
self._session.mount("http://", adapter)
2024
session.auth = (api_key, api_secret) # Basic authentication.
2125
session.headers.update({"User-Agent": user_agent})
2226

0 commit comments

Comments
 (0)