Kaydet (Commit) 15b22e7d authored tarafından Joffrey F's avatar Joffrey F

Merge pull request #292 from mpetazzoni/stop-timeout

Stop timeout should be added to the request timeout
...@@ -873,7 +873,7 @@ class Client(requests.Session): ...@@ -873,7 +873,7 @@ class Client(requests.Session):
params = {'t': timeout} params = {'t': timeout}
url = self._url("/containers/{0}/stop".format(container)) url = self._url("/containers/{0}/stop".format(container))
res = self._post(url, params=params, res = self._post(url, params=params,
timeout=max(timeout, self._timeout)) timeout=(timeout + self._timeout))
self._raise_for_status(res) self._raise_for_status(res)
def tag(self, image, repository, tag=None, force=False): def tag(self, image, repository, tag=None, force=False):
......
...@@ -934,27 +934,30 @@ class DockerClientTest(Cleanup, unittest.TestCase): ...@@ -934,27 +934,30 @@ class DockerClientTest(Cleanup, unittest.TestCase):
) )
def test_stop_container(self): def test_stop_container(self):
timeout = 2
try: 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: except Exception as e:
self.fail('Command should not raise exception: {0}'.format(e)) self.fail('Command should not raise exception: {0}'.format(e))
fake_request.assert_called_with( fake_request.assert_called_with(
url_prefix + 'containers/3cc2351ab11b/stop', url_prefix + 'containers/3cc2351ab11b/stop',
params={'t': 2}, params={'t': timeout},
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS timeout=(docker.client.DEFAULT_TIMEOUT_SECONDS + timeout)
) )
def test_stop_container_with_dict_instead_of_id(self): def test_stop_container_with_dict_instead_of_id(self):
timeout = 2
try: 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: except Exception as e:
self.fail('Command should not raise exception: {0}'.format(e)) self.fail('Command should not raise exception: {0}'.format(e))
fake_request.assert_called_with( fake_request.assert_called_with(
url_prefix + 'containers/3cc2351ab11b/stop', url_prefix + 'containers/3cc2351ab11b/stop',
params={'t': 2}, params={'t': timeout},
timeout=docker.client.DEFAULT_TIMEOUT_SECONDS timeout=(docker.client.DEFAULT_TIMEOUT_SECONDS + timeout)
) )
def test_kill_container(self): def test_kill_container(self):
......
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