Skip to content

module __init__() is called multiple times #30873

@orenbenmeir

Description

@orenbenmeir

In the documentation it is the init() function will be called only one time in the lifecycle of a module. I've cases were it is being called multiple times.

# a.jl
module a
function __init__()
	println("$(@__MODULE__)::__init")
end
end

# b.jl
module b
function __init__()
	println("$(@__MODULE__)::__init")
end
end

# c.jl
module c
import a
import b
end

# d.jl
module d
import c
import b
end


julia> using d
[ Info: Precompiling d [top-level]
a::__init
b::__init
b::__init
a::__init
b::__init
a::__init

This will happen only the first time when the module is not precompiled. Consecutive calls will call __init() only once for each module.
I've a case were the pre-compilation is broken due to dependencies with old packages and it is causing the multiple invocations cause other problems.
I've tested it both with Julia 1.0.3 and with version 1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions