Skip to content

Commit e577f5d

Browse files
author
Ulysses Souza
committed
Sets a different default number of pools to SSH
This is because default the number of connections in OpenSSH is 10 Signed-off-by: Ulysses Souza <[email protected]>
1 parent ac92219 commit e577f5d

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

docker/api/client.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
from .. import auth
2323
from ..constants import (
2424
DEFAULT_TIMEOUT_SECONDS, DEFAULT_USER_AGENT, IS_WINDOWS_PLATFORM,
25-
DEFAULT_DOCKER_API_VERSION, STREAM_HEADER_SIZE_BYTES, DEFAULT_NUM_POOLS,
26-
MINIMUM_DOCKER_API_VERSION
25+
DEFAULT_DOCKER_API_VERSION, MINIMUM_DOCKER_API_VERSION,
26+
STREAM_HEADER_SIZE_BYTES, DEFAULT_NUM_POOLS_SSH, DEFAULT_NUM_POOLS
2727
)
2828
from ..errors import (
2929
DockerException, InvalidVersion, TLSParameterError,
@@ -101,7 +101,7 @@ class APIClient(
101101

102102
def __init__(self, base_url=None, version=None,
103103
timeout=DEFAULT_TIMEOUT_SECONDS, tls=False,
104-
user_agent=DEFAULT_USER_AGENT, num_pools=DEFAULT_NUM_POOLS,
104+
user_agent=DEFAULT_USER_AGENT, num_pools=None,
105105
credstore_env=None):
106106
super(APIClient, self).__init__()
107107

@@ -132,6 +132,10 @@ def __init__(self, base_url=None, version=None,
132132
base_url = utils.parse_host(
133133
base_url, IS_WINDOWS_PLATFORM, tls=bool(tls)
134134
)
135+
# SSH has a different default for num_pools to all other adapters
136+
num_pools = num_pools or DEFAULT_NUM_POOLS_SSH if \
137+
base_url.startswith('ssh://') else DEFAULT_NUM_POOLS
138+
135139
if base_url.startswith('http+unix://'):
136140
self._custom_adapter = UnixAdapter(
137141
base_url, timeout, pool_connections=num_pools

docker/constants.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,10 @@
1818

1919
DEFAULT_USER_AGENT = "docker-sdk-python/{0}".format(version)
2020
DEFAULT_NUM_POOLS = 25
21+
22+
# The OpenSSH server default value for MaxSessions is 10 which means we can
23+
# use up to 9, leaving the final session for the underlying SSH connection.
24+
# For more details see: https://github.com/docker/docker-py/issues/2246
25+
DEFAULT_NUM_POOLS_SSH = 9
26+
2127
DEFAULT_DATA_CHUNK_SIZE = 1024 * 2048

0 commit comments

Comments
 (0)