@@ -16,10 +16,13 @@ Prepare the command we are going to use. It prints "hello stdout"
1616in `stdout `, followed by "hello stderr" in `stderr `:
1717
1818>>> cmd = ' /bin/sh -c "echo hello stdout ; echo hello stderr >&2"'
19+
1920We'll run this command with all four the combinations of ``stream ``
2021and ``demux ``.
22+
2123With ``stream=False `` and ``demux=False ``, the output is a string
2224that contains both the `stdout ` and the `stderr ` output:
25+
2326>>> res = container.exec_run(cmd, stream = False , demux = False )
2427>>> res.output
2528b'hello stderr\nhello stdout\n'
@@ -52,15 +55,8 @@ Traceback (most recent call last):
5255 File "<stdin>", line 1, in <module>
5356StopIteration
5457
55- Finally, with ``stream=False `` and ``demux=True ``, the whole output
56- is returned, but the streams are still separated:
58+ Finally, with ``stream=False `` and ``demux=True ``, the output is a tuple ``(stdout, stderr) ``:
5759
58- >>> res = container.exec_run(cmd, stream = True , demux = True )
59- >>> next (res.output)
60- (b'hello stdout\n', None)
61- >>> next (res.output)
62- (None, b'hello stderr\n')
63- >>> next (res.output)
64- Traceback (most recent call last):
65- File "<stdin>", line 1, in <module>
66- StopIteration
60+ >>> res = container.exec_run(cmd, stream = False , demux = True )
61+ >>> res.output
62+ (b'hello stdout\n', b'hello stderr\n')
0 commit comments