-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
bpo-38267: Add thread timeout parameter to loop.shutdown_default_executor()
#16360
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
Closed
aeros
wants to merge
26
commits into
python:main
from
aeros:bpo-38267-shutdown_default_executor-timeout
Closed
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
700cf86
Add thread timeout constant
aeros 1e7794b
Add timeout param to `loop.shutdown_default_executor()`
aeros a262c45
Set timeout param default to None
aeros b1bb810
Update `loop.shutdown_default_executor() docstring
aeros 8a4c30c
Move constant to runners.py
aeros ebc1b99
Add thread timeout for `asyncio.run()`
aeros 5b90766
Update `asyncio.run()` docstring for `shutdown_default_executor()`
aeros f189f04
Update `asyncio.run()` docstring for thread timeout
aeros 16921a1
Update `asyncio.run()` docs
aeros b678818
Fix whitespace in `asyncio.run()` docstring
aeros e332257
Update `shutdown_default_executor()` docs
aeros 7f8428b
Patchcheck
aeros 577b2b2
📜🤖 Added by blurb_it.
blurb-it[bot] b673080
Fix Misc/NEWS Sphinx role
aeros 926de3f
Merge branch 'master' into bpo-38267-shutdown_default_executor-timeout
aeros f7c623c
Fix documentation for timeout parameter
aeros 169d2d4
Fix documentation for timeout parameter
aeros f0dde2d
Fix asyncio.run() docs
aeros b7c0608
Fix loop.shutdown_default_executor() docstring
aeros 1e95afb
Fix loop.shutdown_default_executor docs
aeros 2b1f35d
Fix loop.shutdown_default_executor()
aeros e549996
Fix asyncio.run() docstring
aeros 8a5121c
Fix runners.py comment
aeros 4264c04
Fix warning
aeros e9a0f19
Fix RuntimeWarning
aeros d9c2e37
Fix style nits
gvanrossum File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix whitespace in
asyncio.run()
docstring
- Loading branch information
commit b6788188f31215d8d40f3c550fec6679073c8ec5
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
@1st1 While writing the documentation, I was thinking that @asvetlov's suggestion to add timeout as parameter for
asyncio.run()
might be beneficial. Although it would add an additional knob for users to adjust, forcing them to strictly use a 5 minute timeout duration seems a bit restrictive.Do you think it might be useful to give users the option to adjust the timeout duration by adding a timeout parameter to
asynio.run()
? Since you regularly interact with daily users of asyncio, you might have a better idea of whether or not that would be useful.Uh oh!
There was an error while loading. Please reload this page.
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.
I think that adding knobs is only justified when there's request for that from users. In this particular case it's a bit tricky.
The way I think about it is that it's easy to implement whatever timeout is necessary with the following pattern:
The argument for this pattern is that in more or less advanced asyncio applications there's always a "runner()" like in the above. It usually sets up signal handlers, manages global state, etc.
asyncio.run()
in those cases is simply providing a set of reasonable defaults on how you run your event loop and how you shut it down. And 5 minutes is a reasonable default in this case, I guess.Long story short, I'd go with this design and learn from our users if we need to make it configurable.
This is just my opinion on this and I'd love to hear what @asvetlov thinks about it.
Uh oh!
There was an error while loading. Please reload this page.
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.
Ah, I actually hadn't thought as much about how relatively simple it would be for the users to create their own runner. I wonder if it would be worthwhile to document this pattern somewhere in
asyncio-task.rst
, for those who desire further customization.Yeah 5 minutes seems reasonable for most purposes. If it's an issue, we can easily adjust it by modifying the constant.
Good point. It might be a better idea to leave out the parameter initially and then add it in later if the users request it. It would be easy to add the new parameter to the API for
asyncio.run()
if it's desired, but it's incredibly difficult to remove parameters in the future.Personally I have no issue with either of the options, I think both of them would be viable. After reading your latest response, I'm leaning more in favor of keeping the current iteration though.
The more I've been involved with API design, I've increasingly come to realize that there's frequently some degree of disconnect between what the users actually want and what the developers think the users want. It can definitely be worthwhile to start with a minimalist approach and add features based on user feedback, rather than making assumptions. Making too many assumptions can easily lead to feature bloat.