The following redirect_stdout
code works as expected in REPL
original_stdout = stdout
(rd, wr) = redirect_stdout()
println("123")
println("456")
redirect_stdout(original_stdout)
close(wr)
read(rd, String)
The output is "123\n456\n"
.
However, if we paste the above code into IJulia (a Jupyter notebook), the last line read
will block. Any suggestions on using redirect_stdout
in IJulia?
julia> versioninfo()
Julia Version 1.5.0
Commit 96786e22cc (2020-08-01 23:44 UTC)
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-9.0.1 (ORCJIT, sandybridge)