Skip to content

Commit 530b4c5

Browse files
vaniakovxginn8
authored andcommitted
Add pool size parameter to client constructor (influxdata#534)
* Add pool size parameter to client constructor * come back removed newlines * fix flake8: line too long * Cast InfluxDBClient pool_size parameter to int * Move pool_size parameter to the end of args to prevent tests fail
1 parent 16c02ec commit 530b4c5

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

influxdb/client.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ class InfluxDBClient(object):
3737
:type username: str
3838
:param password: password of the user, defaults to 'root'
3939
:type password: str
40+
:param pool_size: urllib3 connection pool size, defaults to 10.
41+
:type pool_size: int
4042
:param database: database name to connect to, defaults to None
4143
:type database: str
4244
:param ssl: use https instead of http to connect to InfluxDB, defaults to
@@ -72,6 +74,7 @@ def __init__(self,
7274
use_udp=False,
7375
udp_port=4444,
7476
proxies=None,
77+
pool_size=10,
7578
):
7679
"""Construct a new InfluxDBClient object."""
7780
self.__host = host
@@ -87,6 +90,11 @@ def __init__(self,
8790
self.__use_udp = use_udp
8891
self.__udp_port = udp_port
8992
self._session = requests.Session()
93+
adapter = requests.adapters.HTTPAdapter(
94+
pool_connections=int(pool_size),
95+
pool_maxsize=int(pool_size)
96+
)
97+
9098
if use_udp:
9199
self.udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
92100

@@ -95,6 +103,8 @@ def __init__(self,
95103
if ssl is True:
96104
self._scheme = "https"
97105

106+
self._session.mount(self._scheme, adapter)
107+
98108
if proxies is None:
99109
self._proxies = {}
100110
else:

0 commit comments

Comments
 (0)