Skip to content
Open
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
96e1e78
Add the multiple interpreters howto doc.
ericsnowcurrently Jul 16, 2024
e5e980e
Drop extraneous changes.
ericsnowcurrently Jun 19, 2025
2fcaedd
Finish howto doc, minus recipes.
ericsnowcurrently Jun 20, 2025
aea8278
Add a TODO list.
ericsnowcurrently Jun 26, 2025
4bb1e2f
Drop the execcomponents ref.
ericsnowcurrently Jun 30, 2025
d1ab402
Fix a ref.
ericsnowcurrently Jun 30, 2025
1c2d40f
Drop the examples section for now.
ericsnowcurrently Jun 30, 2025
ade2ce3
Fix typos.
ericsnowcurrently Jul 1, 2025
40f50e7
Add a misc section to the tutorial.
ericsnowcurrently Jul 1, 2025
0c3105b
Clarify about prepare_main().
ericsnowcurrently Jul 1, 2025
6028349
Fix a pseudo-ref.
ericsnowcurrently Jul 1, 2025
d7a7cf0
Fix the examples.
ericsnowcurrently Jul 1, 2025
fb13944
Tweak one example.
ericsnowcurrently Jul 1, 2025
72e46fb
Add a ref.
ericsnowcurrently Jul 2, 2025
675246d
Clarify about Interpreter.exec().
ericsnowcurrently Jul 3, 2025
22e3ee0
Clarify about calling different kinds of function.
ericsnowcurrently Jul 3, 2025
f7661da
Clarify a note.
ericsnowcurrently Jul 3, 2025
28f0218
Add a caveat about -c and the REPL.
ericsnowcurrently Jul 3, 2025
1b79755
Add a pro tip.
ericsnowcurrently Jul 3, 2025
b75c380
Add run-examples.py and fix some of the examples.
ericsnowcurrently Sep 23, 2025
35101a0
Do not try reformatting run-examples.py.
ericsnowcurrently Sep 24, 2025
ddae34c
Fix some of the examples.
ericsnowcurrently Sep 24, 2025
652abd3
Do not lint run-examples.py.
ericsnowcurrently Sep 24, 2025
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
Prev Previous commit
Next Next commit
Add a misc section to the tutorial.
  • Loading branch information
ericsnowcurrently committed Jul 1, 2025
commit 40f50e7bbf42d44808610053cce172d50926572f
49 changes: 28 additions & 21 deletions Doc/howto/multiple-interpreters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ module.

This document has 2 parts: first a brief introduction and then a tutorial.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
This document has 2 parts: first a brief introduction and then a tutorial.
This document has two parts: first a brief introduction and then a tutorial.


The tutorial covers the basics of using multiple interpreters
(:ref:`interp-tutorial-basics`), as well as how to communicate between
interpreters (:ref:`interp-tutorial-communicating`).
The tutorial covers :ref:`the basics <interp-tutorial-basics>` of using
multiple interpreters, as well as how :ref:`to communicate
<interp-tutorial-communicating>` between interpreters. It finishes with
some :ref:`extra information <interp-tutorial-misc>`.

.. currentmodule:: concurrent.interpreters

Expand Down Expand Up @@ -620,24 +621,6 @@ can explicitly clean it up sooner::
finally:
interp.close()

concurrent.futures.InterpreterPoolExecutor
------------------------------------------

The :mod:`concurrent.futures` module is a simple, popular concurrency
framework that wraps both threading and multiprocessing. You can also
use it with multiple interpreters, via
:class:`~concurrent.futures.InterpreterPoolExecutor`::

from concurrent.futures import InterpreterPoolExecutor

def script():
return 'spam!'

with InterpreterPoolExecutor(max_workers=5) as executor:
fut = executor.submit(script)
res = fut.result()
# res: 'spam!'


.. _interp-tutorial-communicating:

Expand Down Expand Up @@ -1015,6 +998,30 @@ You can also close the pipe ends and join the thread to synchronize.
Using :func:`os.pipe` (or similar) to communicate between interpreters
is a little awkward, as well as inefficient.


.. _interp-tutorial-misc:

Tutorial: Miscellaneous
=======================
Comment on lines +1272 to +1273
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
Tutorial: Miscellaneous
=======================
Tutorial: miscellaneous
=======================


concurrent.futures.InterpreterPoolExecutor
------------------------------------------

The :mod:`concurrent.futures` module is a simple, popular concurrency
framework that wraps both threading and multiprocessing. You can also
use it with multiple interpreters, via
:class:`~concurrent.futures.InterpreterPoolExecutor`::

from concurrent.futures import InterpreterPoolExecutor

def script():
return 'spam!'

with InterpreterPoolExecutor(max_workers=5) as executor:
fut = executor.submit(script)
res = fut.result()
# res: 'spam!'

Capturing an interpreter's stdout
---------------------------------

Expand Down