Kaydet (Commit) ff993dd8 authored tarafından grahamlyons's avatar grahamlyons

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: 's avatargrahamlyons <graham@grahamlyons.com>
üst ee75a1c2
...@@ -83,7 +83,8 @@ class APIClient( ...@@ -83,7 +83,8 @@ class APIClient(
configuration. configuration.
user_agent (str): Set a custom user agent for requests to the server. user_agent (str): Set a custom user agent for requests to the server.
""" """
def __init__(self, base_url=None, version=None, timeout=None, tls=False, def __init__(self, base_url=None, version=None,
timeout=DEFAULT_TIMEOUT_SECONDS, tls=False,
user_agent=DEFAULT_USER_AGENT, num_pools=DEFAULT_NUM_POOLS): user_agent=DEFAULT_USER_AGENT, num_pools=DEFAULT_NUM_POOLS):
super(APIClient, self).__init__() super(APIClient, self).__init__()
...@@ -93,11 +94,7 @@ class APIClient( ...@@ -93,11 +94,7 @@ class APIClient(
) )
self.base_url = base_url self.base_url = base_url
if timeout is not None: self.timeout = timeout
self.timeout = timeout
else:
self.timeout = DEFAULT_TIMEOUT_SECONDS
self.headers['User-Agent'] = user_agent self.headers['User-Agent'] = user_agent
self._auth_configs = auth.load_config() self._auth_configs = auth.load_config()
......
from .api.client import APIClient from .api.client import APIClient
from .constants import DEFAULT_TIMEOUT_SECONDS
from .models.containers import ContainerCollection from .models.containers import ContainerCollection
from .models.images import ImageCollection from .models.images import ImageCollection
from .models.networks import NetworkCollection from .models.networks import NetworkCollection
...@@ -73,7 +74,7 @@ class DockerClient(object): ...@@ -73,7 +74,7 @@ class DockerClient(object):
.. _`SSL version`: .. _`SSL version`:
https://docs.python.org/3.5/library/ssl.html#ssl.PROTOCOL_TLSv1 https://docs.python.org/3.5/library/ssl.html#ssl.PROTOCOL_TLSv1
""" """
timeout = kwargs.pop('timeout', None) timeout = kwargs.pop('timeout', DEFAULT_TIMEOUT_SECONDS)
version = kwargs.pop('version', None) version = kwargs.pop('version', None)
return cls(timeout=timeout, version=version, return cls(timeout=timeout, version=version,
**kwargs_from_env(**kwargs)) **kwargs_from_env(**kwargs))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment