Skip to content

Commit 443a353

Browse files
authored
Fix container.stats infinite blocking on stream mode (#3120)
fix: api - container.stats infinite blocking on stream mode Includes additional test for no streaming Signed-off-by: Bharath Vignesh J K <[email protected]>
1 parent 576e47a commit 443a353

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

docker/api/container.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,8 +1164,9 @@ def stats(self, container, decode=None, stream=True, one_shot=None):
11641164
'one_shot is only available in conjunction with '
11651165
'stream=False'
11661166
)
1167-
return self._stream_helper(self._get(url, params=params),
1168-
decode=decode)
1167+
return self._stream_helper(
1168+
self._get(url, stream=True, params=params), decode=decode
1169+
)
11691170
else:
11701171
if decode:
11711172
raise errors.InvalidArgument(

tests/unit/api_container_test.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,10 +1528,21 @@ def test_container_stats(self):
15281528
fake_request.assert_called_with(
15291529
'GET',
15301530
url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/stats',
1531+
stream=True,
15311532
timeout=60,
15321533
params={'stream': True}
15331534
)
15341535

1536+
def test_container_stats_without_streaming(self):
1537+
self.client.stats(fake_api.FAKE_CONTAINER_ID, stream=False)
1538+
1539+
fake_request.assert_called_with(
1540+
'GET',
1541+
url_prefix + 'containers/' + fake_api.FAKE_CONTAINER_ID + '/stats',
1542+
timeout=60,
1543+
params={'stream': False}
1544+
)
1545+
15351546
def test_container_stats_with_one_shot(self):
15361547
self.client.stats(
15371548
fake_api.FAKE_CONTAINER_ID, stream=False, one_shot=True)

0 commit comments

Comments
 (0)