Skip to content

Commit ff993dd

Browse files
committed
Move default timeout into from_env
We'd like to be able to pass `None` as a value for `timeout` because it has meaning to the `requests` library (http://docs.python-requests.org/en/master/user/advanced/#timeouts) Signed-off-by: grahamlyons <graham@grahamlyons.com>
1 parent ee75a1c commit ff993dd

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

docker/api/client.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ class APIClient(
8383
configuration.
8484
user_agent (str): Set a custom user agent for requests to the server.
8585
"""
86-
def __init__(self, base_url=None, version=None, timeout=None, tls=False,
86+
def __init__(self, base_url=None, version=None,
87+
timeout=DEFAULT_TIMEOUT_SECONDS, tls=False,
8788
user_agent=DEFAULT_USER_AGENT, num_pools=DEFAULT_NUM_POOLS):
8889
super(APIClient, self).__init__()
8990

@@ -93,11 +94,7 @@ def __init__(self, base_url=None, version=None, timeout=None, tls=False,
9394
)
9495

9596
self.base_url = base_url
96-
if timeout is not None:
97-
self.timeout = timeout
98-
else:
99-
self.timeout = DEFAULT_TIMEOUT_SECONDS
100-
97+
self.timeout = timeout
10198
self.headers['User-Agent'] = user_agent
10299

103100
self._auth_configs = auth.load_config()

docker/client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from .api.client import APIClient
2+
from .constants import DEFAULT_TIMEOUT_SECONDS
23
from .models.containers import ContainerCollection
34
from .models.images import ImageCollection
45
from .models.networks import NetworkCollection
@@ -73,7 +74,7 @@ def from_env(cls, **kwargs):
7374
.. _`SSL version`:
7475
https://docs.python.org/3.5/library/ssl.html#ssl.PROTOCOL_TLSv1
7576
"""
76-
timeout = kwargs.pop('timeout', None)
77+
timeout = kwargs.pop('timeout', DEFAULT_TIMEOUT_SECONDS)
7778
version = kwargs.pop('version', None)
7879
return cls(timeout=timeout, version=version,
7980
**kwargs_from_env(**kwargs))

0 commit comments

Comments
 (0)