Can't capture the output of print() in a worker process

Why is it that when I print() something in a worker process that doesn’t end with a newline char \n, I don’t capture it in the stdout of the master process, but if I use println() I do?

For example consider the following MWE:

using Distributed

addprocs(1)

@everywhere function hello()
   print("hi!")
end

@spawnat 2 hello();

and I see nothing. But if I use print("hi!\n") or use println(), I see the message printed.

1 Like

Some systems does not print in the output standard (yes in the error standard) until the new line is indicated (by buffer reason). After the print add a println, and you should see it.

Thanks. I also suspected it may be related to buffering. But even if I add flush(stdout) after the print, still nothing shows up. Maybe there is another buffer related to the piping of the worker’s stdout to the master’s?

1 Like