Assume I have a module SomeModule.jl:
module SomeModule
export use_me
function use_me()
println("I'm useful!")
end
function call_me_in_the_end()
println("This is the end")
end
atexit(call_me_in_the_end)
end
And main.jl using this module:
import SomeModule: use_me
use_me()
Since function passed into atexit is called at process exit I expect to see when calling main.jl:
I'm useful!
This is the end
But instead I'm getting:
This is the end
I'm useful!
on the first call, and only:
I'm useful!
for all subsequent calls, until I make changes in SomeModule.jl. After changes are made everything repeats.
I've tried to bring atexit outside of the module, like so:
module SomeModule
...
end
import SomeModule: call_me_in_the_end
atexit(call_me_in_the_end)
but result is the same.
So, two questions:
- Why
call_me_in_the_endis called only once and how to fix it? - How to make
call_me_in_the_endbe called in the end?
Julia's version is 1.7.3 for macOS x86