Skip to content

Commit e843937

Browse files
committed
Allow the maxsize parameter to be passed to the urllib3 connection pool
1 parent 5557fbf commit e843937

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

elasticsearch/connection/http_urllib3.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ class Urllib3HttpConnection(Connection):
1515
:arg http_auth: optional http auth information as either ':' separated
1616
string or a tuple
1717
:arg use_ssl: use ssl for the connection if `True`
18+
:arg maxsize: the maximum number of connections which will be kept open to
19+
this host. Useful to set this higher than 1 for multithreaded situations.
1820
"""
19-
def __init__(self, host='localhost', port=9200, http_auth=None, use_ssl=False, **kwargs):
21+
def __init__(self, host='localhost', port=9200, http_auth=None, use_ssl=False, maxsize=1, **kwargs):
2022
super(Urllib3HttpConnection, self).__init__(host=host, port=port, **kwargs)
2123
headers = {}
2224
if http_auth is not None:
@@ -28,7 +30,7 @@ def __init__(self, host='localhost', port=9200, http_auth=None, use_ssl=False, *
2830
if use_ssl:
2931
pool_class = urllib3.HTTPSConnectionPool
3032

31-
self.pool = pool_class(host, port=port, timeout=kwargs.get('timeout', None), headers=headers)
33+
self.pool = pool_class(host, port=port, timeout=kwargs.get('timeout', None), headers=headers, maxsize=maxsize)
3234

3335
def perform_request(self, method, url, params=None, body=None, timeout=None, ignore=()):
3436
url = self.url_prefix + url

0 commit comments

Comments
 (0)