You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Would this be a helpful function to include in Base? I wrote it for some debugging work (and contrib/generate_precompile.jl has a copy of this already for debugging)
# returns a new stream that has the identical content to `in`, but also "tees"# the `transform(readavailable(in)::Vector{UInt8})` first to `out`functiontee(f, in::IO)
copy = Base.BufferStream()
t =@asynctrywhile!eof(in)
l =readavailable(in)
f(l)
write(copy, l)
endcatch ex
if!(ex isa Base.IOError && ex.code == Base.UV_EIO)
rethrow() # ignore EIO on `in` streamendfinally#TODO: could we call closewrite to propagate an error, instead of always doing a clean close here?closewrite(copy)
end
Base.errormonitor(t)
return copy
endtee(out::IO, in::IO) =tee(l ->write(out, l), in)
# tee((in, out)::Pair) = (in::IO; out::IO; tee(l -> write(out, l), in))
The text was updated successfully, but these errors were encountered:
Would this be a helpful function to include in Base? I wrote it for some debugging work (and contrib/generate_precompile.jl has a copy of this already for debugging)
The text was updated successfully, but these errors were encountered: