diff options
author | RazCrimson <52282402+RazCrimson@users.noreply.github.com> | 2023-05-08 05:21:24 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-07 19:51:24 -0400 |
commit | 443a35360fc426479d87c810ffca8e5a253408a1 (patch) | |
tree | 5c86145230fe97c76d31443b5009d52c3196cf67 | |
parent | 576e47aaacf690a3fdd6cf98c345d48ecf834b7d (diff) | |
download | docker-py-443a35360fc426479d87c810ffca8e5a253408a1.tar.gz |
Fix container.stats infinite blocking on stream mode (#3120)6.1.1
fix: api - container.stats infinite blocking on stream mode
Includes additional test for no streaming
Signed-off-by: Bharath Vignesh J K <52282402+RazCrimson@users.noreply.github.com>
-rw-r--r-- | docker/api/container.py | 5 | ||||
-rw-r--r-- | tests/unit/api_container_test.py | 11 |
2 files changed, 14 insertions, 2 deletions
diff --git a/docker/api/container.py b/docker/api/container.py index fef7603..40607e7 100644 --- a/docker/api/container.py +++ b/docker/api/container.py @@ -1164,8 +1164,9 @@ class ContainerApiMixin: 'one_shot is only available in conjunction with ' 'stream=False' ) - return self._stream_helper(self._get(url, params=params), - decode=decode) + return self._stream_helper( + self._get(url, stream=True, params=params), decode=decode + ) else: if decode: raise errors.InvalidArgument( diff --git a/tests/unit/api_container_test.py b/tests/unit/api_container_test.py index c605da3..c4e2250 100644 --- a/tests/unit/api_container_test.py +++ b/tests/unit/api_container_test.py @@ -1528,10 +1528,21 @@ class ContainerTest(BaseAPIClientTest): fake_request.assert_called_with( 'GET', url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/stats', + stream=True, timeout=60, params={'stream': True} ) + def test_container_stats_without_streaming(self): + self.client.stats(fake_api.FAKE_CONTAINER_ID, stream=False) + + fake_request.assert_called_with( + 'GET', + url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/stats', + timeout=60, + params={'stream': False} + ) + def test_container_stats_with_one_shot(self): self.client.stats( fake_api.FAKE_CONTAINER_ID, stream=False, one_shot=True) |