From 877381546aa2ad737c4d9c2cca045b3f9cc30da3 Mon Sep 17 00:00:00 2001 From: Min RK Date: Mon, 23 Apr 2018 12:40:28 +0200 Subject: [PATCH] make async pool thread count configurable and default to 1 for putting requests in the background without triggering concurrency. --- .../src/main/resources/python/api_client.mustache | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/python/api_client.mustache b/modules/swagger-codegen/src/main/resources/python/api_client.mustache index e24347edf04..a6fe533dd94 100644 --- a/modules/swagger-codegen/src/main/resources/python/api_client.mustache +++ b/modules/swagger-codegen/src/main/resources/python/api_client.mustache @@ -40,6 +40,8 @@ class ApiClient(object): the API. :param cookie: a cookie to include in the header when making calls to the API + :param pool_threads: The number of threads to use for async requests + to the API. More threads means more concurrent API requests. """ PRIMITIVE_TYPES = (float, bool, bytes, six.text_type) + six.integer_types @@ -56,10 +58,11 @@ class ApiClient(object): _pool = None def __init__(self, configuration=None, header_name=None, header_value=None, - cookie=None): + cookie=None, pool_threads=1): if configuration is None: configuration = Configuration() self.configuration = configuration + self.pool_threads = pool_threads self.rest_client = rest.RESTClientObject(configuration) self.default_headers = {} @@ -82,7 +85,7 @@ class ApiClient(object): avoids instantiating unused threadpool for blocking clients. """ if self._pool is None: - self._pool = ThreadPool() + self._pool = ThreadPool(self.pool_threads) return self._pool @property