Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevent package_callbacks to run multiple time for a single package #54243

Merged
merged 1 commit into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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