Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-136380: Fix import behavior for concurrent.futures.InterpreterPoolExecutor#136381

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
sobolevn merged 15 commits intopython:mainfromaisk:import-interpreter-pool-executor
Jul 8, 2025

Conversation

@aisk
Copy link
Contributor

@aiskaisk commentedJul 7, 2025
edited
Loading

It's hard to write the test, but on my local machine, when remove the_interpreters module or raise aModuleNotFoundError in the try branch, the behavior is correct compare to a normal non-exist field:

>>> from concurrent.futures import InterpreterPoolExecutorTraceback (most recent call last):  File "<python-input-0>", line 1, in <module>    from concurrent.futures import InterpreterPoolExecutorImportError: cannot import name 'InterpreterPoolExecutor' from 'concurrent.futures' (C:\Users\xxxxx\Source\cpython\Lib\concurrent\futures\__init__.py)>>> from concurrent import futures>>> futures.InterpreterPoolExecutorTraceback (most recent call last):  File "<python-input-2>", line 1, in <module>    futures.InterpreterPoolExecutor  File "C:\Users\xxxxx\Source\cpython\Lib\concurrent\futures\__init__.py", line 69, in __getattr__          raise AttributeError(f"module {__name__!r} has no attribute {name!r}")AttributeError: module 'concurrent.futures' has no attribute 'InterpreterPoolExecutor'
>>> from concurrent.futures import NotExistTraceback (most recent call last):  File "<python-input-0>", line 1, in <module>    from concurrent.futures import NotExistImportError: cannot import name 'NotExist' from 'concurrent.futures' (C:\Users\xxxxx\Source\cpython\Lib\concurrent\futures\__init__.py)>>> from concurrent import futures>>> futures.NotExistTraceback (most recent call last):  File "<python-input-2>", line 1, in <module>    futures.NotExist  File "C:\Users\xxxxx\Source\cpython\Lib\concurrent\futures\__init__.py", line 69, in __getattr__          raise AttributeError(f"module {__name__!r} has no attribute {name!r}")AttributeError: module 'concurrent.futures' has no attribute 'NotExist'

We mustimport _interpreters in__init__.py to determine whether to append theInterpreterPoolExecutor to__all__. This may have a negative impact on importing performance.

@aiskaisk changed the titleFix import behavior for concurrent.futures.InterpreterPoolExecutorgh-136380: Fix import behavior for concurrent.futures.InterpreterPoolExecutorJul 7, 2025
Copy link
Member

@serhiy-storchakaserhiy-storchaka left a comment

Choose a reason for hiding this comment

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

The downside of this is that_interpreters is now always imported.

Could you add tests? It is not easy, the tests should removeconcurrent and all its submodules recursively fromsys.module, and restoresys.module at the end. There are helpers for this somewhere, they can be private.

Copy link
Member

@ZeroIntensityZeroIntensity left a comment

Choose a reason for hiding this comment

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

aiskand others added4 commitsJuly 8, 2025 01:20
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
…b_nXl.rstCo-authored-by: Peter Bierma <zintensitydev@gmail.com>
@aisk
Copy link
ContributorAuthor

aisk commentedJul 7, 2025

The downside of this is that_interpreters is now always imported.

Could you add tests? It is not easy, the tests should removeconcurrent and all its submodules recursively fromsys.module, and restoresys.module at the end. There are helpers for this somewhere, they can be private.

Found a way to test it by running the test within a subprocess.

Copy link
Member

@serhiy-storchakaserhiy-storchaka left a comment

Choose a reason for hiding this comment

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

LGTM. 👍

@ZeroIntensity
Copy link
Member

I didn't mean to hit the update button, sorry about that.

aiskand others added3 commitsJuly 8, 2025 22:02
Co-authored-by: sobolevn <mail@sobolevn.me>
Copy link
Member

@sobolevnsobolevn left a comment

Choose a reason for hiding this comment

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

Thank you!

@sobolevnsobolevnenabled auto-merge (squash)July 8, 2025 13:18
@sobolevnsobolevn added the needs backport to 3.14bugs and security fixes labelJul 8, 2025
@sobolevnsobolevn merged commit490eea0 intopython:mainJul 8, 2025
42 checks passed
@miss-islington-app
Copy link

Thanks@aisk for the PR, and@sobolevn for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestJul 8, 2025
…terPoolExecutor` (pythonGH-136381)(cherry picked from commit490eea0)Co-authored-by: AN Long <aisk@users.noreply.github.com>Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>Co-authored-by: Peter Bierma <zintensitydev@gmail.com>Co-authored-by: sobolevn <mail@sobolevn.me>
@bedevere-app
Copy link

GH-136420 is a backport of this pull request to the3.14 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.14bugs and security fixes labelJul 8, 2025
@aiskaisk deleted the import-interpreter-pool-executor branchJuly 8, 2025 13:36
sobolevn added a commit that referenced this pull requestJul 8, 2025
…eterPoolExecutor` (GH-136381) (#136420)gh-136380: Fix import behavior for `concurrent.futures.InterpreterPoolExecutor` (GH-136381)(cherry picked from commit490eea0)Co-authored-by: AN Long <aisk@users.noreply.github.com>Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>Co-authored-by: Peter Bierma <zintensitydev@gmail.com>Co-authored-by: sobolevn <mail@sobolevn.me>
AndPuQing pushed a commit to AndPuQing/cpython that referenced this pull requestJul 11, 2025
…terPoolExecutor` (python#136381)Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>Co-authored-by: Peter Bierma <zintensitydev@gmail.com>Co-authored-by: sobolevn <mail@sobolevn.me>
Pranjal095 pushed a commit to Pranjal095/cpython that referenced this pull requestJul 12, 2025
…terPoolExecutor` (python#136381)Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>Co-authored-by: Peter Bierma <zintensitydev@gmail.com>Co-authored-by: sobolevn <mail@sobolevn.me>
picnixz pushed a commit to picnixz/cpython that referenced this pull requestJul 13, 2025
…terPoolExecutor` (python#136381)Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>Co-authored-by: Peter Bierma <zintensitydev@gmail.com>Co-authored-by: sobolevn <mail@sobolevn.me>
@henryiii
Copy link
Contributor

This broke tab completion anddir(concurrent.futures), I've opened a fix in#137214.

taegyunkim pushed a commit to taegyunkim/cpython that referenced this pull requestAug 4, 2025
…terPoolExecutor` (python#136381)Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>Co-authored-by: Peter Bierma <zintensitydev@gmail.com>Co-authored-by: sobolevn <mail@sobolevn.me>
Agent-Hellboy pushed a commit to Agent-Hellboy/cpython that referenced this pull requestAug 19, 2025
…terPoolExecutor` (python#136381)Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>Co-authored-by: Peter Bierma <zintensitydev@gmail.com>Co-authored-by: sobolevn <mail@sobolevn.me>
kumaraditya303 pushed a commit to miss-islington/cpython that referenced this pull requestSep 9, 2025
…nterpreterPoolExecutor` (pythonGH-136381) (python#136420)pythongh-136380: Fix import behavior for `concurrent.futures.InterpreterPoolExecutor` (pythonGH-136381)(cherry picked from commit490eea0)Co-authored-by: AN Long <aisk@users.noreply.github.com>Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>Co-authored-by: Peter Bierma <zintensitydev@gmail.com>Co-authored-by: sobolevn <mail@sobolevn.me>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@ZeroIntensityZeroIntensityZeroIntensity left review comments

@serhiy-storchakaserhiy-storchakaserhiy-storchaka approved these changes

@sobolevnsobolevnsobolevn approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@aisk@ZeroIntensity@henryiii@serhiy-storchaka@sobolevn

[8]ページ先頭

©2009-2025 Movatter.jp