Skip to content

Commit 84414e3

Browse files
authored
fix user_guides/multiplex.rst (#3130)
Signed-off-by: Longin-Yu <longinyh@gmail.com>
1 parent 78439eb commit 84414e3

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

docs/user_guides/multiplex.rst

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,13 @@ Prepare the command we are going to use. It prints "hello stdout"
1616
in `stdout`, followed by "hello stderr" in `stderr`:
1717

1818
>>> cmd = '/bin/sh -c "echo hello stdout ; echo hello stderr >&2"'
19+
1920
We'll run this command with all four the combinations of ``stream``
2021
and ``demux``.
22+
2123
With ``stream=False`` and ``demux=False``, the output is a string
2224
that contains both the `stdout` and the `stderr` output:
25+
2326
>>> res = container.exec_run(cmd, stream=False, demux=False)
2427
>>> res.output
2528
b'hello stderr\nhello stdout\n'
@@ -52,15 +55,8 @@ Traceback (most recent call last):
5255
File "<stdin>", line 1, in <module>
5356
StopIteration
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

Comments
 (0)