mirror of https://github.com/docker/docker-py.git
Fix session timeout = None case
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
da028d88a2
commit
ae8f77737c
|
@ -1018,9 +1018,10 @@ class ContainerApiMixin(object):
|
||||||
"""
|
"""
|
||||||
params = {'t': timeout}
|
params = {'t': timeout}
|
||||||
url = self._url("/containers/{0}/restart", container)
|
url = self._url("/containers/{0}/restart", container)
|
||||||
res = self._post(
|
conn_timeout = self.timeout
|
||||||
url, params=params, timeout=timeout + (self.timeout or 0)
|
if conn_timeout is not None:
|
||||||
)
|
conn_timeout += timeout
|
||||||
|
res = self._post(url, params=params, timeout=conn_timeout)
|
||||||
self._raise_for_status(res)
|
self._raise_for_status(res)
|
||||||
|
|
||||||
@utils.check_resource('container')
|
@utils.check_resource('container')
|
||||||
|
@ -1110,11 +1111,9 @@ class ContainerApiMixin(object):
|
||||||
params = {'t': timeout}
|
params = {'t': timeout}
|
||||||
url = self._url("/containers/{0}/stop", container)
|
url = self._url("/containers/{0}/stop", container)
|
||||||
conn_timeout = self.timeout
|
conn_timeout = self.timeout
|
||||||
if conn_timeout:
|
if conn_timeout is not None:
|
||||||
conn_timeout = max(conn_timeout, timeout + 15)
|
conn_timeout += timeout
|
||||||
res = self._post(
|
res = self._post(url, params=params, timeout=conn_timeout)
|
||||||
url, params=params, timeout=timeout + (self.timeout or 0)
|
|
||||||
)
|
|
||||||
self._raise_for_status(res)
|
self._raise_for_status(res)
|
||||||
|
|
||||||
@utils.check_resource('container')
|
@utils.check_resource('container')
|
||||||
|
|
|
@ -1165,16 +1165,14 @@ class RestartContainerTest(BaseAPIIntegrationTest):
|
||||||
assert info2['State']['Running'] is True
|
assert info2['State']['Running'] is True
|
||||||
self.client.kill(id)
|
self.client.kill(id)
|
||||||
|
|
||||||
def test_restart_with_high_timeout(self):
|
def test_restart_with_low_timeout(self):
|
||||||
container = self.client.create_container(BUSYBOX, ['sleep', '9999'])
|
container = self.client.create_container(BUSYBOX, ['sleep', '9999'])
|
||||||
id = container['Id']
|
self.client.start(container)
|
||||||
self.client.start(id)
|
|
||||||
self.client.timeout = 1
|
self.client.timeout = 1
|
||||||
self.client.restart(id, timeout=3)
|
self.client.restart(container, timeout=3)
|
||||||
self.client.timeout = None
|
self.client.timeout = None
|
||||||
self.client.restart(id, timeout=3)
|
self.client.restart(container, timeout=3)
|
||||||
self.client.timeout = 1
|
self.client.kill(container)
|
||||||
self.client.stop(id, timeout=3)
|
|
||||||
|
|
||||||
def test_restart_with_dict_instead_of_id(self):
|
def test_restart_with_dict_instead_of_id(self):
|
||||||
container = self.client.create_container(BUSYBOX, ['sleep', '9999'])
|
container = self.client.create_container(BUSYBOX, ['sleep', '9999'])
|
||||||
|
|
Loading…
Reference in New Issue