From 5faa764813526195d4ad0bdcfad32a6e1d78be47 Mon Sep 17 00:00:00 2001 From: yuvipanda Date: Sat, 8 Jul 2017 21:06:54 -0700 Subject: [PATCH 1/2] Allow setting maxsize for PoolManager --- configuration.py | 10 +++++++--- rest.py | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/configuration.py b/configuration.py index 0266f93a..23a82c25 100644 --- a/configuration.py +++ b/configuration.py @@ -30,9 +30,7 @@ class ConfigurationObject(object): """ - NOTE: This class is auto generated by the swagger code generator program. - Ref: https://github.com/swagger-api/swagger-codegen - Do not edit the class manually. + Configuration options for RESTClientObject """ def __init__(self): @@ -85,6 +83,12 @@ def __init__(self): # Set this to True/False to enable/disable SSL hostname verification. self.assert_hostname = None + # urllib3 connection pool's maximum number of connections saved + # per pool. Increasing this is useful for cases when you are + # making a lot of possibly parallel requests to the same host, + # which is often the case here. + self.connection_pool_maxsize = 1 + @property def logger_file(self): """ diff --git a/rest.py b/rest.py index e9f484c3..643c5652 100644 --- a/rest.py +++ b/rest.py @@ -97,6 +97,7 @@ def __init__(self, pools_size=4, config=configuration): 'ca_certs': ca_certs, 'cert_file': cert_file, 'key_file': key_file, + 'maxsize': config.connection_pool_maxsize, } if config.assert_hostname is not None: From d339d7cf238fa98f99d481d43942cec3d864fe5e Mon Sep 17 00:00:00 2001 From: yuvipanda Date: Sat, 8 Jul 2017 21:34:01 -0700 Subject: [PATCH 2/2] Only customize maxsize if config is explicitly not set to None --- configuration.py | 3 ++- rest.py | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/configuration.py b/configuration.py index 23a82c25..e2cf0622 100644 --- a/configuration.py +++ b/configuration.py @@ -87,7 +87,8 @@ def __init__(self): # per pool. Increasing this is useful for cases when you are # making a lot of possibly parallel requests to the same host, # which is often the case here. - self.connection_pool_maxsize = 1 + # When set to `None`, will default to whatever urllib3 uses + self.connection_pool_maxsize = None @property def logger_file(self): diff --git a/rest.py b/rest.py index 643c5652..5c2b39ff 100644 --- a/rest.py +++ b/rest.py @@ -97,9 +97,11 @@ def __init__(self, pools_size=4, config=configuration): 'ca_certs': ca_certs, 'cert_file': cert_file, 'key_file': key_file, - 'maxsize': config.connection_pool_maxsize, } + if config.connection_pool_maxsize is not None: + kwargs['maxsize'] = config.connection_pool_maxsize + if config.assert_hostname is not None: kwargs['assert_hostname'] = config.assert_hostname