The method 'pfunc.showData' isn't able to see the variable `data`, which exists as a global variable in the worker's 'Main' module, not it's 'pfuncs' module.
On Saturday, October 31, 2015 at 12:14:34 AM UTC-5, Andre Bieler wrote: > > I have a similar question about getting data to all workers. Consider the > following code: > > ''' > addprocs(2) > using pfuncs > > #= > @everywhere function showData() > @show(data) > end > =# > > function pstep() > @sync begin > for p in workers() > @async begin > remotecall_fetch(p, showData) > end > end > end > end > > @everywhere data = myid() > pstep() > ''' > > If I uncomment the part where the showData() function is defined, it works > as expected. If I put the definition of showData() into the file pfuncs.jl > and import it as in the example above, it does not work. > > From the manual I figure > > "using DummyModule causes the module to be loaded on all processes; > however, the module is brought into scope only on the one executing the > statement." > > addresses the problem, but does not help me solve it. > I also tried the let block posted by Jameson. > > How do I get the same behaviour as with the @everywhere function > definition in the commented block but being able to use modules? > > For completeness here is the pfuncs.jl module: > > ''' > module pfuncs > export showData > > function showData() > @show(data) > end > > end > ''' > > > >
