Add a section about interpreter isolation. (#400)
This commit is contained in:
parent
2164c30c3d
commit
d04497d60c
33
pep-0554.rst
33
pep-0554.rst
|
@ -14,8 +14,8 @@ Abstract
|
|||
|
||||
This proposal introduces the stdlib ``interpreters`` module. It exposes
|
||||
the basic functionality of subinterpreters that already exists in the
|
||||
C-API. Each subinterpreter runs with its own state, including its own
|
||||
copy of all modules, classes, functions, and variables.
|
||||
C-API. Each subinterpreter runs with its own state (see
|
||||
``Interpreter Isolation`` below).
|
||||
|
||||
|
||||
Rationale
|
||||
|
@ -133,12 +133,41 @@ interpreters via queues. The minimal solution (running a source string)
|
|||
is sufficient for us to get the feature out where it can be explored.
|
||||
|
||||
|
||||
Interpreter Isolation
|
||||
=====================
|
||||
|
||||
CPython's interpreters are intended to be strictly isolated from each
|
||||
other. Each interpreter has its own copy of all modules, classes,
|
||||
functions, and variables. The same applies to state in C, including in
|
||||
extension modules. The CPython C-API docs explain more. [c-api]_
|
||||
|
||||
However, there are ways in which interpreters share some state. First
|
||||
of all, some process-global state remains shared, like file descriptors.
|
||||
There are no plans to change this.
|
||||
|
||||
Second, some isolation is faulty due to bugs or implementations that did
|
||||
not take subinterpreters into account. This includes things like
|
||||
at-exit handlers and extension modules that rely on C globals. In these
|
||||
cases bugs should be opened (some are already).
|
||||
|
||||
Finally, some potential isolation is missing due to the current design
|
||||
of CPython. This includes the GIL and memory management. Improvements
|
||||
are currently going on to address gaps in this area.
|
||||
|
||||
|
||||
Open Questions
|
||||
==============
|
||||
|
||||
* Add queues to the proposal anyway?
|
||||
|
||||
|
||||
References
|
||||
==========
|
||||
|
||||
.. [c-api]
|
||||
https://docs.python.org/3/c-api/init.html#bugs-and-caveats
|
||||
|
||||
|
||||
Copyright
|
||||
=========
|
||||
|
||||
|
|
Loading…
Reference in New Issue