In testing my package I have problems to print from an asynchronous task to the REPL. Here is a MWE:
struct Msg
a
b
end
function tpr(ch::Channel)
while true
msg = take!(ch)
if msg isa Msg
println(msg.a, " ", msg.b) # should print one line + CR
else
break
end
end
end
ch = Channel(tpr) # I setup tpr as a task on a channel
If I send a message to my task, I get the following:
julia> put!(ch, Msg("first", "second"))
first secondMsg
("first", "second")
julia> put!(ch, Msg("first", "second"));
first
julia>
julia>
- case (without
;
) I get theCR
after the command has returned (not after the task printout). - case (with
;
) I am loosing the 2nd message argument entirely.
Am I missing something? How can I print correctly from a task? Any advice?
versioninfo()
julia> versioninfo()
Julia Version 1.4.2
Commit 44fa15b150* (2020-05-23 18:35 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin18.7.0)
CPU: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-8.0.1 (ORCJIT, skylake)
Environment:
JULIA_NUM_THREADS = 8
JULIA_EDITOR = atom -a