From 84414e343e526cf93f285284dd2c2c40f703e4a9 Mon Sep 17 00:00:00 2001 From: Hao Yu <129033897+Longin-Yu@users.noreply.github.com> Date: Wed, 7 Jun 2023 02:28:15 +0800 Subject: [PATCH] fix user_guides/multiplex.rst (#3130) Signed-off-by: Longin-Yu --- docs/user_guides/multiplex.rst | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/docs/user_guides/multiplex.rst b/docs/user_guides/multiplex.rst index 78d7e372..7add69b1 100644 --- a/docs/user_guides/multiplex.rst +++ b/docs/user_guides/multiplex.rst @@ -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' @@ -52,15 +55,8 @@ Traceback (most recent call last): File "", line 1, in 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 "", line 1, in -StopIteration +>>> res = container.exec_run(cmd, stream=False, demux=True) +>>> res.output +(b'hello stdout\n', b'hello stderr\n') \ No newline at end of file