@@ -16,10 +16,13 @@ Prepare the command we are going to use. It prints "hello stdout"
16
16
in `stdout `, followed by "hello stderr" in `stderr `:
17
17
18
18
>>> cmd = ' /bin/sh -c "echo hello stdout ; echo hello stderr >&2"'
19
+
19
20
We'll run this command with all four the combinations of ``stream ``
20
21
and ``demux ``.
22
+
21
23
With ``stream=False `` and ``demux=False ``, the output is a string
22
24
that contains both the `stdout ` and the `stderr ` output:
25
+
23
26
>>> res = container.exec_run(cmd, stream = False , demux = False )
24
27
>>> res.output
25
28
b'hello stderr\nhello stdout\n'
@@ -52,15 +55,8 @@ Traceback (most recent call last):
52
55
File "<stdin>", line 1, in <module>
53
56
StopIteration
54
57
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) ``:
57
59
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