Skip to content

Commit d9e08ae

Browse files
committed
Disallow incompatible combination stats(decode=True, stream=False)
Signed-off-by: Joffrey F <[email protected]>
1 parent ebfba8d commit d9e08ae

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

docker/api/container.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1071,7 +1071,8 @@ def stats(self, container, decode=None, stream=True):
10711071
Args:
10721072
container (str): The container to stream statistics from
10731073
decode (bool): If set to true, stream will be decoded into dicts
1074-
on the fly. False by default.
1074+
on the fly. Only applicable if ``stream`` is True.
1075+
False by default.
10751076
stream (bool): If set to false, only the current stats will be
10761077
returned instead of a stream. True by default.
10771078
@@ -1085,6 +1086,10 @@ def stats(self, container, decode=None, stream=True):
10851086
return self._stream_helper(self._get(url, stream=True),
10861087
decode=decode)
10871088
else:
1089+
if decode:
1090+
raise errors.InvalidArgument(
1091+
"decode is only available in conjuction with stream=True"
1092+
)
10881093
return self._result(self._get(url, params={'stream': False}),
10891094
json=True)
10901095

docker/models/containers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,8 @@ def stats(self, **kwargs):
385385
386386
Args:
387387
decode (bool): If set to true, stream will be decoded into dicts
388-
on the fly. False by default.
388+
on the fly. Only applicable if ``stream`` is True.
389+
False by default.
389390
stream (bool): If set to false, only the current stats will be
390391
returned instead of a stream. True by default.
391392

0 commit comments

Comments
 (0)