Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix user_guides/multiplex.rst #3130

Merged
merged 2 commits into from
Jun 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 7 additions & 11 deletions docs/user_guides/multiplex.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ Prepare the command we are going to use. It prints "hello stdout"
in `stdout`, followed by "hello stderr" in `stderr`:

>>> cmd = '/bin/sh -c "echo hello stdout ; echo hello stderr >&2"'

We'll run this command with all four the combinations of ``stream``
and ``demux``.

With ``stream=False`` and ``demux=False``, the output is a string
that contains both the `stdout` and the `stderr` output:

>>> res = container.exec_run(cmd, stream=False, demux=False)
>>> res.output
b'hello stderr\nhello stdout\n'
Expand Down Expand Up @@ -52,15 +55,8 @@ Traceback (most recent call last):
File "<stdin>", line 1, in <module>
StopIteration

Finally, with ``stream=False`` and ``demux=True``, the whole output
is returned, but the streams are still separated:
Finally, with ``stream=False`` and ``demux=True``, the output is a tuple ``(stdout, stderr)``:

>>> res = container.exec_run(cmd, stream=True, demux=True)
>>> next(res.output)
(b'hello stdout\n', None)
>>> next(res.output)
(None, b'hello stderr\n')
>>> next(res.output)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
StopIteration
>>> res = container.exec_run(cmd, stream=False, demux=True)
>>> res.output
(b'hello stdout\n', b'hello stderr\n')