Hi,

I would like to retrieve an arbitrary object from an arbitrary process in a 
worker pool. After some digging I found the function

getfrom(p::Int, nm::Symbol; mod=Main) = fetch(@spawnat(p, getfield(mod, nm)))

in ParallelDataTransfer.jl 
<https://github.com/ChrisRackauckas/ParallelDataTransfer.jl> inspired by 
this post 
<http://stackoverflow.com/questions/27677399/julia-how-to-copy-data-to-another-processor-in-julia>
. 

However, when I tested it out I found some unexpected behaviour. The issue 
is that when I update a field remotely using `remotecall
` and then use getfrom(), it doesn't give me the correct object. However, 
when i hardcode the field in `remotecall()`  I get the expected result. 

Perhaps the issue is best illustrated with a toy example using a type 
called `foo`.

addprocs(1)
import ParallelDataTransfer
@everywhere using ParallelDataTransfer
@everywhere type foo
a
b
c
end

Then i define an instance of the type and send it to all of the workers.

*julia> **srand(30);*


*julia> **foo1 = foo(rand(3),rand(3),rand(3));  # Define an instance of 
foo1*


*julia> **ParallelDataTransfer.sendto(workers(),foo1=foo1);  # Put foo1 on 
all workers*


*julia> **foo1.c    # Print output of field c                            *

*3-element Array{Float64,1}:*

* 0.369435*

* 0.671903*

* 0.321753*

Now I would like to mutate `foo1.c` on worker 2 and use `remotecall_fetch` 
to check that the field is changed.

*julia> **remotecall(()->Main.foo1.c=ones(3),2)  # Mutate Main.foo1.c on 
worker 2.  *

*Future(2,1,17,Nullable{Any}())*


*julia> **remotecall_fetch(()->Main.foo1.c,2)   # Confirms the change and 
works as expected*

*3-element Array{Float64,1}:*

* 1.0*

* 1.0*

* 1.0*

Now I would like, in principle, to use the `getfrom()` function in 
ParallelDataTransfer.jl to retrieve the mutated field on my current 
process. However, when I run it I get the field prior to mutation.

*julia> **ParallelDataTransfer.getfrom(2, :c, mod=Main.foo1) *

*3-element Array{Float64,1}:*

* 0.369435*

* 0.671903*

* 0.321753*

Does anyone know why `getfrom` is not retrieving the mutated field? Is 
there a fix?

Thanks
Alan

Reply via email to