-
-
Notifications
You must be signed in to change notification settings - Fork 30.6k
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
Custom environments in subinterpreters #126977
Comments
I'd say this is probably the main issue with this proposal, but I don't know the specifics. This is already an issue right now, but is exacerbated here, as it increases the likeliness of users running into it. We should consider possible preventive or mitigation measures. Regarding 2.1), most modern Linux environments don't hit 2.1), as loaded symbols aren't loaded globally, unless Regarding 2.2), AFAICT, this means that global data in the extension and its dependencies is shared between subinterpreters. Similarly, we could possibly mitigate this by detecting it and raising If these, or any other aspects of 2), are still problematic, we could simply prevent loading extension modules on subinterpreters that have a custom environment. |
First reaction: I'm skeptical that we actually want this as stated? subinterpreters having different environment configs than the main interpreter doesn't feel right. Would we want to support that explicitly as a feature for everyone to build on and depend on?
This is a much more direct thing to ask for and could be implemented as a feature on its own without allowing arbitrary whole new environment configs. Gut feeling: whole new configs contain a can of worms of potentially unintended consequences. I expect Eric and others with their head in (sub)interpreter startup land to have a better feel for the reality of my gut check here. |
This can still happen with some subset of symbols. For example GNU's extension 'unique global' symbols will still end in the global namespace even if you open with All of this is to say that it will be quite difficult to detect the poisoning unless we require that the shared object exports no symbols other than the |
This is not possible to detect but a module supporting two phase initialisation should be safe to load because it should have its global state on the module state and two sub interpreters will share it. The problem will be something like a logging singleton in some internal dependency: initialising the logging singleton will initialise in all sub interpreters at the same time but you cannot just hard fail because that's how is supposed to work. |
Feature or enhancement
Proposal:
I wanted to explore the viability of having custom environments in subinterpreters. There are several use-cases that could be enabled by this feature.
So far, from informal discussion with others about this, there are a couple possible issues to take into consideration.
Issues
2.1) Symbol conflicts from their dependencies (pointed out by @Yhg1s)
2.2) Since subinterpreters share the same process, when loading the same shared object, they get the same pointer (pointed out by @pablogsal)
Implementation
The main thing we need is a way to disable the
site
initialization, which could be aenable_site
option in the interpreter config. This should disable the environment customizations, and result in a bare environment without anything extrasys.path
.However, to make the use of different environments more ergonomic, we could add an
environment_path
location pointing to a directory containing apyvenv.cfg
, which would perform thesite
initialization for that environment.Has this already been discussed elsewhere?
No response given
Links to previous discussion of this feature:
No response
The text was updated successfully, but these errors were encountered: