Skip to content

Commit

Permalink
make async pool thread count configurable
Browse files Browse the repository at this point in the history
and default to 1 for putting requests in the background
without triggering concurrency.
  • Loading branch information
minrk committed Apr 23, 2018
1 parent 687f6d5 commit e4e758e
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 = {}
Expand All @@ -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
Expand Down

0 comments on commit e4e758e

Please sign in to comment.