-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
gh-95601: restore support for awaitable objects that are not futures in asyncio.wait
#95708
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
gh-95601: restore support for awaitable objects that are not futures in asyncio.wait
#95708
Conversation
asyncio.wait
and deprecate that support
Lib/asyncio/tasks.py
Outdated
if coroutines.iscoroutine(f): | ||
raise TypeError("Passing coroutines is forbidden, use tasks explicitly.") | ||
if not futures.isfuture(f): | ||
warnings.warn( |
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.
Use warnings._deprecated
?
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.
Yeah I usually would, but I kinda want to try backport the deprecation fix to 3.10
also the wording warnings._deprecated
doesn't work too well for changes in behaviour and I didn't want to try and fix it and open a new can of worms there
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.
@hugovk are you already working on a plan to upbraid all the existing warnings.warn(..., DeprecationWarning)
to warnings._deprecated
?
there's a slight usability/wording concern when using it for changes in behavior instead of actual full removals
and there also seems to be a desire to use it for totally unscheduled removals: remove=(4, )
in addition do you have a view on backporting deprecation, where it was clear from the code what the intention of the deprecation was, but the deprecation itself had a bug?
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.
@hugovk are you already working on a plan to upbraid all the existing
warnings.warn(..., DeprecationWarning)
towarnings._deprecated
?
I'm not but that's a good idea. From a quick check, there's not too many, and most are set to be removed in 3.12 anyway.
there's a slight usability/wording concern when using it for changes in behavior instead of actual full removals
Can you alter the wording using the message
parameter?
and there also seems to be a desire to use it for totally unscheduled removals:
remove=(4, )
Some removals scheduled for 4.0 were from before we knew if 3.10 or 4.0 would follow 3.9 (#80480 (comment)) and in at least one case is shorthand for "sometime after 2.7.final" (#80480 (comment)).
Anyway, we should review any remaining removals originally set for 4.0 (e.g. in new issues or relevant open issues) to decide if they can be removed in an upcoming 3.x.
in addition do you have a view on backporting deprecation, where it was clear from the code what the intention of the deprecation was, but the deprecation itself had a bug?
Generally, I think it's a good idea to increase visibility and help users upgrade in time to reduce friction. It's good to ask release managers when in doubt.
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.
@hugovk do you think we have enough here to make a new issue out of this side discussion. Or maybe there's two to four ideas here:
- Do something about existing deprecation warnings that don't automatically get upgraded to errors
- Do something about the wording and format-string templating in warnings._deprecated to make it work for even the most subtle behaviour change
- Determine a backport strategy for when a deprecation warning was applied to the wrong thing
- Determine a strategy for permanent deprecations, where a feature is a bit broken or an alias of another thing, and people should really use the not broken way or source of the alias, but CPython is unwilling or undecided on actually removing it
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.
Sure! Or at https://discuss.python.org/?
Misc/NEWS.d/next/Library/2022-08-05-11-16-33.gh-issue-95601.hJvI9y.rst
Outdated
Show resolved
Hide resolved
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
…vI9y.rst Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
this is undoing a removal that didn't go via the deprecation policy, and then applying a deprecation for restored functionality |
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
Please don't add release-blocker labels without talking to Pablo first. |
asyncio.wait
and deprecate that supportasyncio.wait
@tiran recommended spitting this PR into two, one that restores the functionality removed without deprecation and one that does the deprecation. |
a4c6c1c
to
a5c5f4a
Compare
Misc/NEWS.d/next/Library/2022-08-05-11-16-33.gh-issue-95601.hJvI9y.rst
Outdated
Show resolved
Hide resolved
It seems that the function was always supposed to only support futures and tasks. If you want to add support of arbitrary awaitables, it should be a new feature. And you need to update the documentation, the docstring and error messages to reflect this. |
that's correct however support for Awaitables is currently available in 3.7, 3.8, 3.9, 3.10 and was removed as a consequence of an incorrectly enforced deprecation in 3.11 I plan to deprecate this support correctly in #96783 |
|
||
for f in fs: | ||
if coroutines.iscoroutine(f): | ||
raise TypeError("Passing coroutines is forbidden, use tasks explicitly.") |
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.
What will happened with implicitly created futures added to new_fs
? Would it emit a warning?
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 removed the warning at @tiran 's request, with a plan to add it in a follow up PR.
I'm happy to put it back in this PR if you'd prefer
@serhiy-storchaka can you re-review this? I'll add the warning if you and @tiran agree it should be added in this PR. |
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.
My previous reviews should be discarded as the code has changed since I reviewed. (I don't think I have the permission to dismiss stale reviews.). Since 3.11 is final now, it can't be backported either. I am hoping that @gvanrossum and @1st1 can handle this for 3.12. |
I think it’s better to start over with a clean slate. |
asyncio.wait
removed in 3.11 #95601asyncio.wait
acceptsconcurrent.futures.Future
objects and other more exotic objects like distributed.Future #95920