-
- Notifications
You must be signed in to change notification settings - Fork 32.3k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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 remove concurrent
and all its submodules recursively from sys.module
, and restore sys.module
at the end. There are helpers for this somewhere, they can be private.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Misc/NEWS.d/next/Library/2025-07-07-22-12-32.gh-issue-136380.1b_nXl.rst Outdated Show resolved Hide resolved
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
…b_nXl.rst Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Found a way to test it by running the test within a subprocess. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. 👍
I didn't mean to hit the update button, sorry about that. |
Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: sobolevn <mail@sobolevn.me>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
…terPoolExecutor` (pythonGH-136381) (cherry picked from commit 490eea0) 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>
GH-136420 is a backport of this pull request to the 3.14 branch. |
…eterPoolExecutor` (GH-136381) (#136420) gh-136380: Fix import behavior for `concurrent.futures.InterpreterPoolExecutor` (GH-136381) (cherry picked from commit 490eea0) 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>
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:We must
import _interpreters
in__init__.py
to determine whether to append theInterpreterPoolExecutor
to__all__
. This may have a negative impact on importing performance.