@@ -51,7 +51,7 @@ include("Docker.jl")
5151# Load the UserNamespace executor
5252include (" UserNamespaces.jl" )
5353
54- all_executors = Type{<: SandboxExecutor }[
54+ const all_executors = Type{<: SandboxExecutor }[
5555 # We always prefer the UserNamespaces executor, if we can use it,
5656 # and the unprivileged one most of all. Only after that do we try `docker`.
5757 UnprivilegedUserNamespacesExecutor,
@@ -89,16 +89,15 @@ function select_executor(verbose::Bool)
8989 error (" Could not find any available executors for $(triplet (HostPlatform ())) !" )
9090end
9191
92- _preferred_executor = nothing
92+ const _preferred_executor = Ref {Union{Nothing, (x->Type{x}).(Sandbox.all_executors)...}} ( nothing )
9393const _preferred_executor_lock = ReentrantLock ()
9494function preferred_executor (;verbose:: Bool = false )
9595 lock (_preferred_executor_lock) do
9696 # If we've already asked this question, return the old answer
97- global _preferred_executor
98- if _preferred_executor === nothing
99- _preferred_executor = select_executor (verbose)
97+ if _preferred_executor[] === nothing
98+ _preferred_executor[] = select_executor (verbose)
10099 end
101- return _preferred_executor
100+ return _preferred_executor[]
102101 end
103102end
104103
0 commit comments