mirror of https://github.com/docker/docker-py.git
Merge pull request #292 from mpetazzoni/stop-timeout
Stop timeout should be added to the request timeout
This commit is contained in:
commit
15b22e7d16
|
@ -873,7 +873,7 @@ class Client(requests.Session):
|
|||
params = {'t': timeout}
|
||||
url = self._url("/containers/{0}/stop".format(container))
|
||||
res = self._post(url, params=params,
|
||||
timeout=max(timeout, self._timeout))
|
||||
timeout=(timeout + self._timeout))
|
||||
self._raise_for_status(res)
|
||||
|
||||
def tag(self, image, repository, tag=None, force=False):
|
||||
|
|
|
@ -934,27 +934,30 @@ class DockerClientTest(Cleanup, unittest.TestCase):
|
|||
)
|
||||
|
||||
def test_stop_container(self):
|
||||
timeout = 2
|
||||
try:
|
||||
self.client.stop(fake_api.FAKE_CONTAINER_ID, timeout=2)
|
||||
self.client.stop(fake_api.FAKE_CONTAINER_ID, timeout=timeout)
|
||||
except Exception as e:
|
||||
self.fail('Command should not raise exception: {0}'.format(e))
|
||||
|
||||
fake_request.assert_called_with(
|
||||
url_prefix + 'containers/3cc2351ab11b/stop',
|
||||
params={'t': 2},
|
||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS
|
||||
params={'t': timeout},
|
||||
timeout=(docker.client.DEFAULT_TIMEOUT_SECONDS + timeout)
|
||||
)
|
||||
|
||||
def test_stop_container_with_dict_instead_of_id(self):
|
||||
timeout = 2
|
||||
try:
|
||||
self.client.stop({'Id': fake_api.FAKE_CONTAINER_ID}, timeout=2)
|
||||
self.client.stop({'Id': fake_api.FAKE_CONTAINER_ID},
|
||||
timeout=timeout)
|
||||
except Exception as e:
|
||||
self.fail('Command should not raise exception: {0}'.format(e))
|
||||
|
||||
fake_request.assert_called_with(
|
||||
url_prefix + 'containers/3cc2351ab11b/stop',
|
||||
params={'t': 2},
|
||||
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS
|
||||
params={'t': timeout},
|
||||
timeout=(docker.client.DEFAULT_TIMEOUT_SECONDS + timeout)
|
||||
)
|
||||
|
||||
def test_kill_container(self):
|
||||
|
|
Loading…
Reference in New Issue