mirror of https://github.com/docker/docker-py.git
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>
This commit is contained in:
parent
ee75a1c2e3
commit
ff993dd858
|
@ -83,7 +83,8 @@ class APIClient(
|
|||
configuration.
|
||||
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):
|
||||
super(APIClient, self).__init__()
|
||||
|
||||
|
@ -93,11 +94,7 @@ class APIClient(
|
|||
)
|
||||
|
||||
self.base_url = base_url
|
||||
if timeout is not None:
|
||||
self.timeout = timeout
|
||||
else:
|
||||
self.timeout = DEFAULT_TIMEOUT_SECONDS
|
||||
|
||||
self.timeout = timeout
|
||||
self.headers['User-Agent'] = user_agent
|
||||
|
||||
self._auth_configs = auth.load_config()
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from .api.client import APIClient
|
||||
from .constants import DEFAULT_TIMEOUT_SECONDS
|
||||
from .models.containers import ContainerCollection
|
||||
from .models.images import ImageCollection
|
||||
from .models.networks import NetworkCollection
|
||||
|
@ -73,7 +74,7 @@ class DockerClient(object):
|
|||
.. _`SSL version`:
|
||||
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)
|
||||
return cls(timeout=timeout, version=version,
|
||||
**kwargs_from_env(**kwargs))
|
||||
|
|
Loading…
Reference in New Issue