# How to NOT interpolate on remote worker?

**URL:** https://discourse.julialang.org/t/how-to-not-interpolate-on-remote-worker/53027
**Category:** General Usage
**Tags:** question, parallel, distributed
**Created:** [January 8, 2021, 6:35am UTC](https://discourse.julialang.org/t/how-to-not-interpolate-on-remote-worker/53027 "2021-01-08T06:35:05Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)
#### Post date: [January 8, 2021, 6:35am UTC](https://discourse.julialang.org/t/how-to-not-interpolate-on-remote-worker/53027/1 "2021-01-08T06:35:05Z")

</div>

```julia
julia> using Distributed

julia> addprocs(2);

julia> @everywhere a = [1,2]

julia> @everywhere println(a)
[1, 2]
      From worker 3: [1, 2]
      From worker 2: [1, 2]

julia> a = 5
5

julia> @everywhere println(a)
5
      From worker 2: [1, 2]
      From worker 3: [1, 2]

julia> @fetchfrom 3 a[2]
ERROR: On worker 3:
BoundsError
Stacktrace:

julia> @everywhere println(a)
5
      From worker 2: [1, 2]
      From worker 3: 5

```

this above behavior is weird, how do I access the `a` on the remote?

My real use case is if I have a `@distributed` for loop, how can I ask Julia NOT to use my local (main process) variable in the body of the loop?

---

<div class="post-metadata">

### Author: ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)
#### Post date: [January 8, 2021, 6:43am UTC](https://discourse.julialang.org/t/how-to-not-interpolate-on-remote-worker/53027/2 "2021-01-08T06:43:39Z")

</div>

for my second question, it seems to be a scoping problem:

as long as `X` does not exist in my main process, the loop body will use the remote variable correctly

---

<div class="post-metadata">

### Author: ![marius311](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marius311/32/3953_2.png) [@marius311](https://discourse.julialang.org/u/marius311)
#### Post date: [January 12, 2021, 3:12am UTC](https://discourse.julialang.org/t/how-to-not-interpolate-on-remote-worker/53027/3 "2021-01-12T03:12:46Z")

</div>

> [@jling](#):
>
> this above behavior is weird, how do I access the `a` on the remote?

Sounds like you got it figured out, but in case its useful, [this](https://docs.julialang.org/en/v1.5/manual/distributed-computing/#Global-variables) is the relevant section, and `@everywhere println(a)` is indeed the correct way to access the value of the global variable `a` on the worker without triggering an auto-send from `a` on the local process (conversely, `@fetchfrom 3 a[2]` triggered the auto-send, hence why it ended up being `5` on that worker).

---

<div class="post-metadata">

### Author: ![marius311](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marius311/32/3953_2.png) [@marius311](https://discourse.julialang.org/u/marius311)
#### Post date: [January 12, 2021, 3:17am UTC](https://discourse.julialang.org/t/how-to-not-interpolate-on-remote-worker/53027/4 "2021-01-12T03:17:40Z")

</div>

The other thing you can do is “hide” accessing the global from the auto-shipping mechanism (and hence prevent auto-sending it) inside an `@eval`, e.g.

```julia
@fetchfrom 3 @eval a[2]

```

will not send `a`, it’ll return the global `a[2]` exactly as it currently exists on the worker.
