Precompile and real time loops

I’m working on a package that includes a real time loop where there is an audio thread and a a “while true” loop that waits for user input in a loop.
When doing “using [PkgName]” in the REPL, it tries to compile it but the main() function gets called and the audio starts playing and the import never returns.
How can avoid this ? I do want to precompile as much of the package as possible because I want to avoid pauses due to the JIT but I want the main function or at least some parts of it not to be executed.
Code is here for reference:

The documentation suggests

if abspath(PROGRAM_FILE) == @__FILE__

Ah indeed, I just had to replace the line


with the snippet you posted. Thank you very much !