Suppressor.jl icon indicating copy to clipboard operation
Suppressor.jl copied to clipboard

Weird and bad things happen if `@surpress` is used in a `@async`

Open oxinabox opened this issue 7 years ago • 2 comments
trafficstars

MVE

In julia 0.7

julia> using Suppressor

julia> function foo()
       @sync for ii in 1:10
       @async begin
           @suppress print(ii)
       end
       end
       println("FIRE")

       end
foo (generic function with 1 method)

julia> foo()
ERROR: SystemError: dup: Bad file descriptor
#systemerror#39(::Nothing, ::Function, ::String, ::Bool) at ./error.jl:106
dup at ./error.jl:106 [inlined]
_redirect_stdout(::Base.PipeEndpoint) at ./stream.jl:923
redirect_stdout(::Base.PipeEndpoint) at ./stream.jl:928
macro expansion at /home/wheel/oxinabox/.julia/packages/Suppressor/qdsy/src/Suppressor.jl:30 [inlined]
macro expansion at ./REPL[2]:4 [inlined]
(::getfield(Main, Symbol("##3#6")))() at ./task.jl:262

...and 4 more exception(s).

Stacktrace:
 [1] sync_end(::Array{Any,1}) at ./task.jl:229
 [2] macro expansion at ./REPL[2]:3 [inlined]
 [3] macro expansion at ./task.jl:247 [inlined]
 [4] foo() at ./REPL[2]:2
 [5] top-level scope at none:0

julia> println("Hi")

julia>

So throws an error and breaks the ability to create output.

I first encountered this in a situation where I was capturing all exceptions, and reprinting them as warnings. Which, because this error breaks the ability to produce output via normal means, no warnings were being displayed. So I was confused to see my code generating an output that looked like a failure case, but that had no warnings being displayed. And man my debugging via @show was confusing.

oxinabox avatar Sep 15 '18 03:09 oxinabox

Any idea what was causing this? I can get the same error running redirect_stderr in doctests.

bramtayl avatar Jul 22 '21 19:07 bramtayl

I've also run into this error trying to use @suppress embedded in asyncmap or @async.

glwagner avatar Nov 18 '22 17:11 glwagner