-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
I have a julia (1.12) file that is structured something like this:
using Distributed
function main()
@everywhere variable = [0, 1, 2, 3, 4, 5]
for x in variable
println(x^2)
end
end
main()From my understanding @everywhere should define the variable on every worker, including the main process.
But when I run the code, it give me this error:
UndefVarError: `variable` not defined in `Main` The binding may be too new: running in world age 38716, while current world is 38717.
In a jupyter notebook, I can run main() again a second time, and then it works, since I assume then the world age matches...
Can someone explain what is going on and if there is some way to circumvent this problem? I can fix it by defining it again in the main process variable = [0, 1, 2, 3, 4, 5], or by taking the code out of the main() function but to me that doesn't feel intended.
Metadata
Metadata
Assignees
Labels
No labels