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

Allow pass-through of output #20

Merged
merged 13 commits into from
Jan 15, 2024
10 changes: 9 additions & 1 deletion src/IOCapture.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,15 @@ function capture(f; rethrow::Type=Any, color::Bool=false)
# pipe to `output` in order to avoid the buffer filling up and stalling write() calls in
# user code.
output = IOBuffer()
buffer_redirect_task = @async write(output, pipe)
bufsize = 128
buffer_redirect_task = @async begin
while true
buffer = read(pipe, bufsize)
goerz marked this conversation as resolved.
Show resolved Hide resolved
write(output, buffer)
write(default_stdout, buffer)
isempty(buffer) && break
end
end

if old_rng !== nothing
copy!(Random.default_rng(), old_rng)
Expand Down