I’m running the following code in Visual Studio Code:
using Distributed, Plots
addprocs(3)
@everywhere begin
using Plots
x = [0, 300]
y = [0, 300]
p = scatter(x, y)
title!(p, "Process: $(myid())")
display(p)
end
@distributed for i = 1:300
# title!(p, "Process: $(myid())")
append!(p, (i, i))
display(p)
end
My expectation is that this will show four plots, one for each process and that the plots will have different titles corresponding to the process id of each plot as determined by myid(). However, instead I get that the four plots each have the same title: “Process: 1”.
That intepolation occurs first, “Process: $(myid())” in macro before calling serialization. That’s why you see 1 in all titles(check with macroexpand). string("Process: ", myid()) prevents that, I think.
I used the modified code below and I still see the behavior in my original post.
using Distributed, Plots
addprocs(3)
@everywhere begin
using Plots; plotly()
x = [0, 300]
y = [0, 300]
p = scatter(x, y)
mid = myid()
title!(p, "Process: $mid")
# display(p)
end
@sync @distributed for i = 1:300
# title!(p, "Process: $(myid())")
append!(p, (i, i))
end
@everywhere begin
display(p)
end