Fix capturing stdout to use @async

pull/66/head
Matti Pastell 2016-11-02 20:03:04 +02:00
parent 3d30e4fcfc
commit 82e56aa9f3
1 changed files with 2 additions and 1 deletions

View File

@ -157,6 +157,7 @@ function capture_output(expr, SandBox::Module, term, disp, plotlib,
out = nothing
obj = nothing
rw, wr = redirect_stdout()
reader = @async readstring(rw)
try
obj = eval(SandBox, expr)
if (term || disp) && typeof(expr) == Expr && expr.head != :toplevel
@ -176,7 +177,7 @@ function capture_output(expr, SandBox::Module, term, disp, plotlib,
finally
redirect_stdout(oldSTDOUT)
close(wr)
out = @compat readstring(rw)
out = wait(reader)
close(rw)
end
return (obj, out)