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

Race conditions for printing when using async=true

Open feanor12 opened this issue 4 years ago • 1 comments

The output to stdout sometimes returns a broken pipe error. I also realized that redirect_stdout might not be a good idea to redirect in an concurrent environment as they influence the global Base.stdout variable.

I created a post on discourse asking how one would generate a module owned stdout. Maybe someone knows a good solution. The one I found was writing to a temporary file instead of stdout by overwriting print and println. Maybe show can also be overwritten.

https://discourse.julialang.org/t/how-to-catch-stdout-per-module/59611

feanor12 avatar Apr 20 '21 08:04 feanor12

Yes, @feanor12 , you are right that redirect_stdout has several problems with concurrent environment. Actually, for using threads/async I need to redirect it manually, but I mantain the redirect because it could not be working in all cases, see

https://github.com/dmolina/DaemonMode.jl/blob/master/src/DaemonMode.jl#L271-L300

Thank you for the post on discourse, I will be attentive to what is said, in order to improve it.

dmolina avatar Apr 20 '21 08:04 dmolina