Skip to content

Conversation

ericsnowcurrently
Copy link
Member

@ericsnowcurrently ericsnowcurrently commented Jun 30, 2025

@ericsnowcurrently ericsnowcurrently added the needs backport to 3.14 bugs and security fixes label Jun 30, 2025
@bedevere-app bedevere-app bot added docs Documentation in the Doc dir skip news labels Jun 30, 2025
@github-project-automation github-project-automation bot moved this to Todo in Docs PRs Jun 30, 2025
@ericsnowcurrently ericsnowcurrently marked this pull request as ready for review June 30, 2025 23:00
are still relatively inefficient and limited
* actually *sharing* data safely is tricky (true for free-threading too)
* all necessary modules must be imported separately in each interpreter
* relatively slow startup time per interpreter
Copy link
Contributor

Choose a reason for hiding this comment

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

Some users might need a (foot)note that subinterpreters can sometimes improve the startup by importing nothing.

example
def non_stateless():
    non_stateless

if __name__ == '__main__':
    import threading
    from concurrent import interpreters
    interps = [interpreters.create() for i in range(10)]
    threads = [
        threading.Thread(target=interp.call, args=(non_stateless,))
        for interp in interps
    ]
    for thread in threads:
        thread.start()
    for thread in threads:
        thread.join()

That seems not so beneficial for the InterpreterPoolExecutor case, though.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've added a note, though further down in the discussion about calling functions.


if __name__ == '__main__':
interp = interpreters.create()
t = interp.call_in_thread(script)
Copy link
Contributor

Choose a reason for hiding this comment

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

Off-topic, but would it be possible to add the daemon parameter to the helper method?

Copy link
Member Author

Choose a reason for hiding this comment

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

I want to keep the helper super simple. If someone wants a daemon thread then they can do it manually without much effort.

@ericsnowcurrently
Copy link
Member Author

Any objections to merging this?

example = dedent(os.linesep.join(current))
expected = ''.join(f'{l}{os.linesep}' for l in expected)
examples[start] = (example, expected)
current = expected = start = None
Copy link
Member

Choose a reason for hiding this comment

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

This line is unused:

Suggested change
current = expected = start = None

Comment on lines +66 to +67
def write_example(examplesdir, name, text):
filename = os.path.join(examplesdir, f'example-{name}.py')
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
def write_example(examplesdir, name, text):
filename = os.path.join(examplesdir, f'example-{name}.py')
def write_example(examples_dir, name, text):
filename = os.path.join(examples_dir, f'example-{name}.py')

Comment on lines +83 to +84
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
capture_output=True,

if failed:
print(f'{len(failed)} failed: {",".join(failed)}')
else:
print(f'all succeeded')
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
print(f'all succeeded')
print('all succeeded')

name: Run Ruff (lint) on Doc/
args: [--exit-non-zero-on-fix]
files: ^Doc/
exclude: ^Doc/howto/multiple-interpreters-run-examples.py
Copy link
Member

Choose a reason for hiding this comment

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

Let's remove these exclusions and do the fixes?

Suggested change
exclude: ^Doc/howto/multiple-interpreters-run-examples.py

Comment on lines +976 to +977
Sharing Data
------------
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Sharing Data
------------
Sharing data
------------

Comment on lines +991 to +992
Using Queues
------------
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Using Queues
------------
Using queues
------------

Comment on lines +1033 to +1034
Initializing Globals for a Script
---------------------------------
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Initializing Globals for a Script
---------------------------------
Initializing globals for a script
---------------------------------

Comment on lines +1125 to +1126
Pipes, Sockets, etc.
--------------------
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Pipes, Sockets, etc.
--------------------
Pipes, sockets, and so on
-------------------------

Avoid Latin abbreviations: https://devguide.python.org/documentation/style-guide/#use-simple-language

Comment on lines +1272 to +1273
Tutorial: Miscellaneous
=======================
Copy link
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
=======================

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review docs Documentation in the Doc dir needs backport to 3.14 bugs and security fixes skip news

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

3 participants