Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth committed Jun 3, 2023
1 parent 07ca9dc commit 67fd0b9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2807,10 +2807,11 @@ function maybe_cachefile_lock(f, pkg::PkgId, srcpath::String)
pidfile = string(srcpath, ".pidlock")
if invokelatest(trymkpidlock_hook, f, pidfile) == false
pid, hostname, age = invokelatest(parse_pidfile_hook, pidfile)
verbosity = isinteractive() ? CoreLogging.Info : CoreLogging.Debug
if isempty(hostname) || hostname == gethostname()
@info "Waiting for another process (pid: $pid) to finish precompiling $pkg"
@logmsg verbosity "Waiting for another process (pid: $pid) to finish precompiling $pkg"
else
@info "Waiting for another machine (hostname: $hostname) to finish precompiling $pkg"
@logmsg verbosity "Waiting for another machine (hostname: $hostname, pid: $pid) to finish precompiling $pkg"
end
# wait until the lock is available, but don't actually acquire it
# returning nothing indicates a process waited for another
Expand Down
8 changes: 4 additions & 4 deletions stdlib/FileWatching/test/pidfile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,14 @@ end
Base.errormonitor(rmtask)

t1 = time()
@test_throws ErrorException open_exclusive("pidfile", wait=false)
@test_throws Pidfile.PidlockedError open_exclusive("pidfile", wait=false)
@test time()-t1 0 atol=1

sleep(1)
@test !deleted

t1 = time()
@test_throws ErrorException open_exclusive("pidfile", wait=false)
@test_throws Pidfile.PidlockedError open_exclusive("pidfile", wait=false)
@test time()-t1 0 atol=1

wait(rmtask)
Expand Down Expand Up @@ -246,7 +246,7 @@ end
Base.errormonitor(waittask)

# mkpidlock with no waiting
t = @elapsed @test_throws ErrorException mkpidlock("pidfile", wait=false)
t = @elapsed @test_throws Pidfile.PidlockedError mkpidlock("pidfile", wait=false)
@test t 0 atol=1

t = @elapsed lockf1 = mkpidlock(joinpath(dir, "pidfile"))
Expand Down Expand Up @@ -354,7 +354,7 @@ end
@test lockf.update === nothing

sleep(1)
t = @elapsed @test_throws ErrorException mkpidlock("pidfile-2", wait=false, stale_age=1, poll_interval=1, refresh=0)
t = @elapsed @test_throws Pidfile.PidlockedError mkpidlock("pidfile-2", wait=false, stale_age=1, poll_interval=1, refresh=0)
@test t 0 atol=1

sleep(5)
Expand Down

0 comments on commit 67fd0b9

Please sign in to comment.