bpo-30439: Add a basic high-level interpreters module. by ericsnowcurrently · Pull Request #1803 · python/cpython · GitHub
Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
90 changes: 90 additions & 0 deletions Doc/library/_interpreters.rst
1 change: 1 addition & 0 deletions Doc/library/concurrency.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ The following are support modules for some of the above services:
dummy_threading.rst
_thread.rst
_dummy_thread.rst
_interpreters.rst
64 changes: 64 additions & 0 deletions Doc/library/interpreters.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
:mod:`interpreters` --- high-level interpreters API
===================================================

.. module:: interpreters
:synopsis: High-level interpreters API.

**Source code:** :source:`Lib/interpreters.py`

.. versionadded:: 3,7

--------------

This module provides high-level interfaces for interacting with
the Python interpreters. It is built on top of the lower- level
:mod:`_interpreters` module.

.. XXX Summarize :ref:`_sub-interpreter-support` here.

This module defines the following functions:

.. function:: enumerate()

Return a list of all existing interpreters.


.. function:: get_current()

Return the currently running interpreter.


.. function:: get_main()

Return the main interpreter.


.. function:: create()

Initialize a new Python interpreter and return it. The
interpreter will be created in the current thread and will remain
idle until something is run in it.


This module also defines the following class:

.. class:: Interpreter(id)

``id`` is the interpreter's ID.

.. property:: id

The interpreter's ID.

.. method:: is_running()

Return whether or not the interpreter is currently running.

.. method:: destroy()

Finalize and destroy the interpreter.

.. method:: run(code)

Run the provided Python code in the interpreter, in the current
OS thread. Supported code: source text.
79 changes: 79 additions & 0 deletions Lib/interpreters.py
Loading