Skip to content

Commit 891dc8d

Browse files
KristofferClazarusA
authored andcommitted
prevent package_callbacks to run multiple time for a single package (JuliaLang#54243)
Introduced in JuliaLang#52841.
1 parent fac7080 commit 891dc8d

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

base/loading.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -2273,7 +2273,7 @@ function __require_prelocked(uuidkey::PkgId, env=nothing)
22732273
run_package_callbacks(uuidkey)
22742274
else
22752275
m = get(loaded_modules, uuidkey, nothing)
2276-
if m !== nothing
2276+
if m !== nothing && !haskey(explicit_loaded_modules, uuidkey)
22772277
explicit_loaded_modules[uuidkey] = m
22782278
run_package_callbacks(uuidkey)
22792279
end

test/precompile.jl

+19
Original file line numberDiff line numberDiff line change
@@ -1331,6 +1331,25 @@ precompile_test_harness("package_callbacks") do dir
13311331
finally
13321332
pop!(Base.package_callbacks)
13331333
end
1334+
Test5_module = :Teste4095a85
1335+
write(joinpath(dir, "$(Test5_module).jl"),
1336+
"""
1337+
module $(Test5_module)
1338+
end
1339+
""")
1340+
Base.compilecache(Base.PkgId("$(Test5_module)"))
1341+
cnt = 0
1342+
push!(Base.package_callbacks, _->(cnt += 1))
1343+
try
1344+
@eval using $(Symbol(Test5_module))
1345+
@eval using $(Symbol(Test5_module))
1346+
@eval using $(Symbol(Test5_module))
1347+
@eval using $(Symbol(Test5_module))
1348+
@eval using $(Symbol(Test5_module))
1349+
@test cnt == 1
1350+
finally
1351+
pop!(Base.package_callbacks)
1352+
end
13341353
end
13351354

13361355
# Issue #19960

0 commit comments

Comments
 (0)