-
Notifications
You must be signed in to change notification settings - Fork 6
2 Open Questions
Eric Snow edited this page Aug 24, 2018
·
13 revisions
The idea is to introduce a mode in which using a subinterpreter is less perilous. This mode could be optional for subinterpreters (at the C level), though it's probably not worth it.
- disallow threading
- disallow forking
- eliminate the GIL within each subinterpreter
- start the subinterpreter in its own thread (and pin it there)
- (maybe) add mode management
...
...
- freelists
- caches
- static types
- singletons
- interned objects
_Py_IDENTIFIER- ...
- store pointer
- good: simpler, faster
- bad: crash if interpreter already destroyed
- requires a per-interpreter refcount
- store ID
- good: safer
- bad: failure when interpreter already destroyed happens at a distance from where interpreter recorded
options:
- keep global state (in
PyRuntimeState) along with per-interpreter - in special cases, treat the state of main interpreter as global
- tracing
- as a global default
- ? warnings
- it would have to be global (not main)
- what would global "warnings" config mean? default?
- ? atexit
- set on main interpreter at C level (no objects owned by subinterpreters can be involved)
- pending calls
- main interpreter already used for signal handlers
- "global" also means "any interpreter"? (not likely)
- ? gc / allocators / etc.
- do we need global memory mgmt. for anything? (maybe)
- ? GIL
- probably not; we'll use granular locks for cross-interpreter stuff
- pending calls
- e.g. for decref of shared objects
- tracing?
- allow one interpreter to manage others
- atexit?
- allow one interpreter to manage others
- gc?
- allow one interpreter to manage others
- move pending calls to
PyThreadState? - also support per-thread tracing?
Signal handlers are triggered through the main interpreter. However, the registered functions should run in the interpreter where the function was created (i.e. the "owning" interpreter). This is due to the isolation requirements of subinterpreters when they do not share the GIL: objects cannot be used outside their owning interpreter.