-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
gh-121333: Clarify what is the default executor for asyncio.run_in_executor #121335
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
Co-authored-by: Kumar Aditya <[email protected]>
Doc/library/asyncio-eventloop.rst
Outdated
The *executor* argument should be an :class:`concurrent.futures.Executor` | ||
instance. The default executor is used if *executor* is ``None``. | ||
The *executor* argument should be a :class:`concurrent.futures.Executor` | ||
instance. The default executor :class:`concurrent.futures.ThreadPoolExecutor` | ||
is used if not set by :meth:`loop.set_default_executor`. |
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.
Sorry to butt in, but this is still pretty imprecise. First the executor
argument may also be None
. Second, the default executor is not just any ThreadPoolExecutor
, it is the default executor of the event loop (loop
), which is always a ThreadPoolExecutor
. This may indeed be set using set_default_executor
, otherwise it is "lazy-initialized" by run_in_executor
if needed.
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.
Thanks for the review, how about this, regardless the format:
The *executor* argument should be a :class:`concurrent.futures.Executor`
instance. The default executor of the event loop is used if *executor* is ``None``.
The default executor can be set by :meth:`loop.set_default_executor`, otherwise,
a :class:`concurrent.futures.ThreadPoolExecutor` will be lazy-initialized by
:func:`run_in_executor` if needed.
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.
Perfect!
Thanks @aisk for the PR, and @kumaraditya303 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12. |
Thanks @aisk for the PR, and @kumaraditya303 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13. |
…_in_executor (pythonGH-121335) (cherry picked from commit facf986) Co-authored-by: AN Long <[email protected]> Co-authored-by: Kumar Aditya <[email protected]>
…_in_executor (pythonGH-121335) (cherry picked from commit facf986) Co-authored-by: AN Long <[email protected]> Co-authored-by: Kumar Aditya <[email protected]>
GH-121525 is a backport of this pull request to the 3.12 branch. |
GH-121526 is a backport of this pull request to the 3.13 branch. |
…n_in_executor (GH-121335) (#121525) gh-121333: Clarify what is the default executor for asyncio.run_in_executor (GH-121335) (cherry picked from commit facf986) Co-authored-by: AN Long <[email protected]> Co-authored-by: Kumar Aditya <[email protected]>
…n_in_executor (GH-121335) (#121526) gh-121333: Clarify what is the default executor for asyncio.run_in_executor (GH-121335) (cherry picked from commit facf986) Co-authored-by: AN Long <[email protected]> Co-authored-by: Kumar Aditya <[email protected]>
…_in_executor (python#121335) Co-authored-by: Kumar Aditya <[email protected]>
…_in_executor (python#121335) Co-authored-by: Kumar Aditya <[email protected]>
asyncio.run_in_executor
#121333📚 Documentation preview 📚: https://cpython-previews--121335.org.readthedocs.build/