# "@everywhere using AAA" causes races on writing precompilation files?

**URL:** <https://discourse.julialang.org/t/everywhere-using-aaa-causes-races-on-writing-precompilation-files/25638>\
**Category:** General Usage\
**Created:** [June 25, 2019, 4:34am UTC](https://discourse.julialang.org/t/everywhere-using-aaa-causes-races-on-writing-precompilation-files/25638 "2019-06-25T04:34:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![RonK](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronk/32/8604_2.png) [@RonK](https://discourse.julialang.org/u/RonK)\
**Post date:** [June 25, 2019, 4:34am UTC](https://discourse.julialang.org/t/everywhere-using-aaa-causes-races-on-writing-precompilation-files/25638/1 "2019-06-25T04:34:10Z")

</div>

It seems to me that the precompiler doesn’t lock files properly to prevent race conditions on generating precompilation files. I have a script which uses the Distributed module which I run on a single multicore computer running Linux, so all the worker threads share the same precompilation cache. The script executes many lines of the form

@everywhere using Module\_AAA

and I have the distinct impression that the precompiler of v. 1.1 doesn’t like this (lots of precompilation errors are generated). If I precompile all included modules by executing a non-parallel script consisting of only the same “using” statements without @everywhere, the precompiler works ok, and then the parallel script subsequently runs without precompilation errors (since all modules are up-to-date in the precompilation cache).

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [June 25, 2019, 6:28am UTC](https://discourse.julialang.org/t/everywhere-using-aaa-causes-races-on-writing-precompilation-files/25638/2 "2019-06-25T06:28:20Z")

</div>

You can load the module on the main process first, e.g.

```julia
using Module_AAA
@everywhere using Module_AAA

```

or you can try out the recent [https://github.com/simonbyrne/PkgLock.jl](https://github.com/simonbyrne/PkgLock.jl) package.

---

<div class="post-metadata">

**Author:** ![RonK](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ronk/32/8604_2.png) [@RonK](https://discourse.julialang.org/u/RonK)\
**Post date:** [June 26, 2019, 4:05am UTC](https://discourse.julialang.org/t/everywhere-using-aaa-causes-races-on-writing-precompilation-files/25638/3 "2019-06-26T04:05:42Z")

</div>

Thanks for the workaround.

And thanks for pointing me to that package, via its description I’ve come to understand that there are similar, if not identical, reported open issues with the precompilation system.

---

<div class="post-metadata">

**Author:** ![bjarthur](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bjarthur/32/9638_2.png) [@bjarthur](https://discourse.julialang.org/u/bjarthur)\
**Post date:** [July 29, 2020, 12:09am UTC](https://discourse.julialang.org/t/everywhere-using-aaa-causes-races-on-writing-precompilation-files/25638/4 "2020-07-29T00:09:56Z")

</div>

another workaround would be to just issue `]precompile` before launching the workers. alas, there is a [bug](https://github.com/JuliaLang/Pkg.jl/issues/1578) in it.
