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

gh-107306: Add a Doc Entry for Py_mod_multiple_interpreters #107403

Merged
merged 4 commits into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Doc/c-api/init.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1287,6 +1287,7 @@ function. You can create and destroy them using the following functions:
in any thread where the sub-interpreter is currently active.
Otherwise only multi-phase init extension modules
(see :pep:`489`) may be imported.
(Also see :c:macro:`Py_mod_multiple_interpreters`.)

This must be ``1`` (non-zero) if
:c:member:`~PyInterpreterConfig.use_main_obmalloc` is ``0``.
Expand Down
29 changes: 29 additions & 0 deletions Doc/c-api/module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,35 @@ The available slot types are:
If multiple ``Py_mod_exec`` slots are specified, they are processed in the
order they appear in the *m_slots* array.

.. c:macro:: Py_mod_multiple_interpreters

Specifies one of the following values:

.. c:macro:: Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED

The module does not support being imported in subinterpreters.

.. c:macro:: Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED

The module supports being imported in subinterpreters,
but only when they share the main interpreter's GIL.
(See :ref:`isolating-extensions-howto`.)

.. c:macro:: Py_MOD_PER_INTERPRETER_GIL_SUPPORTED

The module supports being imported in subinterpreters,
even when they have their own GIL.
(See :ref:`isolating-extensions-howto`.)

This slot determines whether or not importing this module
in a subinterpreter will fail.

Multiple ``Py_mod_multiple_interpreters`` slots may not be specified
in one module definition.

If ``Py_mod_multiple_interpreters`` is not specified, the import
machinery defaults to ``Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED``.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add .. versionadded:: 3.12?

See :PEP:`489` for more details on multi-phase initialization.

Low-level module creation functions
Expand Down
2 changes: 2 additions & 0 deletions Doc/howto/isolating-extensions.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.. highlight:: c

.. _isolating-extensions-howto:

***************************
Isolating Extension Modules
***************************
Expand Down