Skip to content

Commit

Permalink
Precompile: Highlight when the lock is held by the same process (Juli…
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth authored Oct 29, 2023
1 parent 75960e5 commit e79cb86
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/API.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1419,7 +1419,7 @@ function precompile(ctx::Context, pkgs::Vector{PackageSpec}; internal_call::Bool
anim_char_colored = dep in direct_deps ? anim_char : color_string(anim_char, :light_black)
waiting = if haskey(pkgspidlocked, dep)
who_has_lock = pkgspidlocked[dep]
color_string(" Being precompiled by another $(who_has_lock)", Base.info_color())
color_string(" Being precompiled by $(who_has_lock)", Base.info_color())
elseif dep in taskwaiting
color_string(" Waiting for background task / IO / timer. Interrupt to inspect", Base.warn_color())
else
Expand Down Expand Up @@ -1681,12 +1681,16 @@ function maybe_cachefile_lock(f, io::IO, print_lock::ReentrantLock, fancyprint::
if cachefile === false
pid, hostname, age = FileWatching.Pidfile.parse_pidfile(pidfile)
pkgspidlocked[pkg] = if isempty(hostname) || hostname == gethostname()
"process (pid: $pid, pidfile: $pidfile)"
if pid == getpid()
"an async task in this process (pidfile: $pidfile)"
else
"another process (pid: $pid, pidfile: $pidfile)"
end
else
"machine (hostname: $hostname, pid: $pid, pidfile: $pidfile)"
"another machine (hostname: $hostname, pid: $pid, pidfile: $pidfile)"
end
!fancyprint && lock(print_lock) do
println(io, " ", pkg.name, color_string(" Being precompiled by another $(pkgspidlocked[pkg])", Base.info_color()))
println(io, " ", pkg.name, color_string(" Being precompiled by $(pkgspidlocked[pkg])", Base.info_color()))
end
# wait until the lock is available
FileWatching.mkpidlock(pidfile; stale_age) do
Expand Down

0 comments on commit e79cb86

Please sign in to comment.