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

workspace should provide a way to detect already-initialized modules #16467

Closed
stevengj opened this issue May 20, 2016 · 3 comments
Closed

workspace should provide a way to detect already-initialized modules #16467

stevengj opened this issue May 20, 2016 · 3 comments
Labels
help wanted Indicates that a maintainer wants help on an issue or pull request modules
Milestone

Comments

@stevengj
Copy link
Member

For some C libraries (see JuliaIO/Blosc.jl#19), it is not safe to initialize them more than once, nor do we want to register an atexit hook more than once. However, if you do a workspace() then re-import the module, its __init__ is called a second time. It would be good to have a documented way to check whether a module was already initialized in a previous workspace.

(It's not sufficient to look at LastMain because the user could call workspace() twice.)

For example, there could be some kind of module_init_called(modulename) function that looks up a module in a global list of initialized modules that persists across workspace calls.

@yuyichao
Copy link
Contributor

Milestone moved from #18646

@maleadt
Copy link
Member

maleadt commented Oct 20, 2016

Related: calling reload($PKG) does the same, so it would be nice for a fix to span both cases.

@JeffBezanson
Copy link
Member

Fixed by #17997. Now top-level modules are kept in a hidden internal table, so using X in a new Main module just re-references the same module. An explicit reload is needed to actually load again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Indicates that a maintainer wants help on an issue or pull request modules
Projects
None yet
Development

No branches or pull requests

6 participants