Any way to remove "From worker"?

I want to print some data in a distributed for-loop but I don’t really want to see these lines with the “from worker” prefix. Is there any way to get rid of it?

      From worker 3:	hello
      From worker 4:	world
      From worker 2:	foo

you could overwrite the redirected printing function from distributed and omit the “from worker”

using Distributed

Distributed.redirect_worker_output(ident, stream) = begin
    @async while !eof(stream)
        line = readline(stream)
        if startswith(line, "      From worker ")
            # stdout's of "additional" workers started from an initial worker on a host are not available
            # on the master directly - they are routed via the initial worker's stdout.
            parts = split(line,":")
            println(join(parts[2:end]...))
        else
            # println("      From worker $(ident):\t$line")
            println(line)
        end
    end
end
addprocs(1)

@spawn println("hello")
1 Like

I do something similar in a multi-core application I have:

Core.eval(Distributed, :(function redirect_worker_output(ident, stream)
        @async while !eof(stream)
            println(readline(stream))
        end
    end))
1 Like