# How to get persistence on distributed workers

**URL:** <https://discourse.julialang.org/t/how-to-get-persistence-on-distributed-workers/53098>\
**Category:** Performance\
**Tags:** question, distributed\
**Created:** [January 9, 2021, 10:25pm UTC](https://discourse.julialang.org/t/how-to-get-persistence-on-distributed-workers/53098 "2021-01-09T22:25:24Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![affans](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/affans/32/11911_2.png) [@affans](https://discourse.julialang.org/u/affans)\
**Post date:** [January 14, 2021, 7:07pm UTC](https://discourse.julialang.org/t/how-to-get-persistence-on-distributed-workers/53098/7 "2021-01-14T19:07:29Z")

</div>

It’s failing because you are trying to assign to `A` a brand new RHS. Typing in `A = ...` dosn’t “mutate” `A`. It tries to redefine the variable `A` to whatever the RHS is, which is not allowed from another module. (The old binding is actually lost and likely garbage collected). See this thread [on defining variables in other modules.](https://discourse.julialang.org/t/how-can-i-change-variables-of-modules-from-other-files-or-different-modules/15661)

You can fix this by indeed mutating the variable with the broadcast notation, i.e. `@everywhere testmoda.A = [1:nworkers();]` like your first test. If you want to test mutability without broadcast, use a `for` loop or some other mechanism.

```julia
for i in eachindex(A) 
   A[i] = nworkers()[i]
end

```

although again, I imagine this is for learning purposes as there isn’t any difference between the broadcast code vs the for loop.

Also note that `ismutable(testmoda.A)` is fine. It’s not redefining `A`, and indeed tells you at whatever `A` is pointing to can be modified.

---

_[View the full topic](https://discourse.julialang.org/t/how-to-get-persistence-on-distributed-workers/53098)._
