# Share a module between two Worker processes

**URL:** https://discourse.julialang.org/t/share-a-module-between-two-worker-processes/13998
**Category:** General Usage
**Tags:** embedding, parallel
**Created:** [August 24, 2018, 2:01pm UTC](https://discourse.julialang.org/t/share-a-module-between-two-worker-processes/13998 "2018-08-24T14:01:59Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![vitreo12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vitreo12/32/4028_2.png) [@vitreo12](https://discourse.julialang.org/u/vitreo12)
#### Post date: [August 24, 2018, 2:01pm UTC](https://discourse.julialang.org/t/share-a-module-between-two-worker-processes/13998/1 "2018-08-24T14:01:59Z")

</div>

Hello everyone,  
I am currently writing some hard real-time Julia code that relies on importing some modules from source files. The `include` function, though, with long and complex files, is too slow. I was thinking of using a Distributed approach to this, loading the modules from source files in a Worker process and accessing them from another when it is ready. While the modules get imported correctly on the Worker process, I cannot find a way to access such module from another process without having to use the `include` function in such process aswell.  
For now, starting Julia with 2 processes, I tried:

DummyModule.jl source file:

```julia
module Dummy
struct DummyStruct
      a::Int64
end
end

```

I would need to use the DummyStruct in my main process, but the slow include function would stop other real-time calls that I need to do. So I would want to import the module on a second process, and share the module with my main process later on, when it has been correctly included on the second process.

```julia
remotecall(include, 2, "DummyModule.jl")

```

Then, I would want to share the Dummy module with the main process, but I get a `UndefVarError: Dummy not defined` from the main process, while I can use the module only in the second process:

```julia
fetch(@spawnat 2 getfield(Main, :Dummy))

```

Is there a way of sharing a module or a struct definition between the two processes, as I would do with a normal object? I am also open to solutions using just the Julia C API, as I am developing my Julia code inside a C application.

Thanks

---

<div class="post-metadata">

### Author: ![dave.f.kleinschmidt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dave.f.kleinschmidt/32/55_2.png) [@dave.f.kleinschmidt](https://discourse.julialang.org/u/dave.f.kleinschmidt)
#### Post date: [November 7, 2018, 5:37pm UTC](https://discourse.julialang.org/t/share-a-module-between-two-worker-processes/13998/2 "2018-11-07T17:37:30Z")

</div>

I don’t think this is possible, at least based on the [manual](https://docs.julialang.org/en/v1/manual/parallel-computing/index.html#Code-Availability-and-Loading-Packages-1). You’ll need to `include` your source files on every process where the things defined will be used.
