Share a module between two Worker processes

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:

module Dummy
struct DummyStruct

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.

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:

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.


I don’t think this is possible, at least based on the manual. You’ll need to include your source files on every process where the things defined will be used.