diff options
author | Joffrey F <joffrey@docker.com> | 2016-09-12 17:43:50 -0700 |
---|---|---|
committer | Joffrey F <joffrey@docker.com> | 2016-09-12 17:43:50 -0700 |
commit | be7d0f01844d5c08ee157446ce96f5bc6381507c (patch) | |
tree | 7954e3ae1241b4fe5ffbe3e0908d4fb89c969a17 /docker/transport/npipeconn.py | |
parent | 72e7afe17a9aa8b002a726377ce86cc9e13f6f35 (diff) | |
download | docker-py-1207-configurable-num-pools.tar.gz |
Number of pools in adapter is configurable1207-configurable-num-pools
Default increased from 10 to 25
Signed-off-by: Joffrey F <joffrey@docker.com>
Diffstat (limited to 'docker/transport/npipeconn.py')
-rw-r--r-- | docker/transport/npipeconn.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/docker/transport/npipeconn.py b/docker/transport/npipeconn.py index 736ddf6..917fa8b 100644 --- a/docker/transport/npipeconn.py +++ b/docker/transport/npipeconn.py @@ -1,6 +1,7 @@ import six import requests.adapters +from .. import constants from .npipesocket import NpipeSocket if six.PY3: @@ -33,9 +34,9 @@ class NpipeHTTPConnection(httplib.HTTPConnection, object): class NpipeHTTPConnectionPool(urllib3.connectionpool.HTTPConnectionPool): - def __init__(self, npipe_path, timeout=60): + def __init__(self, npipe_path, timeout=60, maxsize=10): super(NpipeHTTPConnectionPool, self).__init__( - 'localhost', timeout=timeout + 'localhost', timeout=timeout, maxsize=maxsize ) self.npipe_path = npipe_path self.timeout = timeout @@ -47,11 +48,12 @@ class NpipeHTTPConnectionPool(urllib3.connectionpool.HTTPConnectionPool): class NpipeAdapter(requests.adapters.HTTPAdapter): - def __init__(self, base_url, timeout=60): + def __init__(self, base_url, timeout=60, + num_pools=constants.DEFAULT_NUM_POOLS): self.npipe_path = base_url.replace('npipe://', '') self.timeout = timeout self.pools = RecentlyUsedContainer( - 10, dispose_func=lambda p: p.close() + num_pools, dispose_func=lambda p: p.close() ) super(NpipeAdapter, self).__init__() |