Skip to content

Commit

Permalink
move cache pidfile to depot while keeping specific to sourcepath
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth committed Jun 19, 2023
1 parent 90521dd commit a41892f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2819,10 +2819,16 @@ global mkpidlock_hook
global trymkpidlock_hook
global parse_pidfile_hook

function cache_pidfile_path(pkg::PkgId, sourcepath::String)
entrypath, entryfile = cache_file_entry(pkg)
srcpath_hash = string(hash(sourcepath), base=16)
return joinpath(entrypath, srcpath_hash * ".pidfile")
end

# allows processes to wait if another process is precompiling a given source already
function maybe_cachefile_lock(f, pkg::PkgId, srcpath::String)
if @isdefined(mkpidlock_hook) && @isdefined(trymkpidlock_hook) && @isdefined(parse_pidfile_hook)
pidfile = string(srcpath, ".pidlock")
pidfile = cache_pidfile_path(pkg, srcpath)
cachefile = invokelatest(trymkpidlock_hook, f, pidfile)
if cachefile === false
pid, hostname, age = invokelatest(parse_pidfile_hook, pidfile)
Expand Down

0 comments on commit a41892f

Please sign in to comment.