Skip to content

Commit

Permalink
prevent package_callbacks to run multiple time for a single package (
Browse files Browse the repository at this point in the history
  • Loading branch information
KristofferC authored and lazarusA committed Jul 12, 2024
1 parent fac7080 commit 891dc8d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2273,7 +2273,7 @@ function __require_prelocked(uuidkey::PkgId, env=nothing)
run_package_callbacks(uuidkey)
else
m = get(loaded_modules, uuidkey, nothing)
if m !== nothing
if m !== nothing && !haskey(explicit_loaded_modules, uuidkey)
explicit_loaded_modules[uuidkey] = m
run_package_callbacks(uuidkey)
end
Expand Down
19 changes: 19 additions & 0 deletions test/precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1331,6 +1331,25 @@ precompile_test_harness("package_callbacks") do dir
finally
pop!(Base.package_callbacks)
end
Test5_module = :Teste4095a85
write(joinpath(dir, "$(Test5_module).jl"),
"""
module $(Test5_module)
end
""")
Base.compilecache(Base.PkgId("$(Test5_module)"))
cnt = 0
push!(Base.package_callbacks, _->(cnt += 1))
try
@eval using $(Symbol(Test5_module))
@eval using $(Symbol(Test5_module))
@eval using $(Symbol(Test5_module))
@eval using $(Symbol(Test5_module))
@eval using $(Symbol(Test5_module))
@test cnt == 1
finally
pop!(Base.package_callbacks)
end
end

# Issue #19960
Expand Down

0 comments on commit 891dc8d

Please sign in to comment.