Skip to content

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

Closed

Conversation

@graingert graingert changed the title gh-95601: forbid non-futures in asyncio.wait gh-95601: restore support for awaitable objects that are not futures in asyncio.wait and deprecate that support Aug 5, 2022
@graingert graingert changed the title gh-95601: restore support for awaitable objects that are not futures in asyncio.wait and deprecate that support gh-95601: restore support for awaitable objects that are not futures in asyncio.wait and deprecate that support Aug 5, 2022
@graingert graingert marked this pull request as ready for review August 5, 2022 11:52
@graingert graingert requested review from 1st1 and asvetlov as code owners August 5, 2022 11:52
if coroutines.iscoroutine(f):
raise TypeError("Passing coroutines is forbidden, use tasks explicitly.")
if not futures.isfuture(f):
warnings.warn(
Copy link
Contributor

Choose a reason for hiding this comment

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

Use warnings._deprecated?

Copy link
Contributor Author

@graingert graingert Aug 9, 2022

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

Copy link
Contributor Author

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?

Copy link
Member

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 ?

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.

Copy link
Contributor Author

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

Copy link
Member

Choose a reason for hiding this comment

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

@kumaraditya303 kumaraditya303 added needs backport to 3.11 only security fixes type-bug An unexpected behavior, bug, or error labels Aug 9, 2022
graingert and others added 4 commits August 9, 2022 15:18
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
…vI9y.rst

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
@graingert
Copy link
Contributor Author

FWIW I don't think this should be deferred blocker. cc @pablogsal

If is adding a deprecation, is a blocker because we certainly won't be able to do it after the first release. It still needs an exemption though

this is undoing a removal that didn't go via the deprecation policy, and then applying a deprecation for restored functionality

Copy link
Contributor

@kumaraditya303 kumaraditya303 left a comment

Choose a reason for hiding this comment

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

LGTM

@gvanrossum
Copy link
Member

Please don't add release-blocker labels without talking to Pablo first.

@graingert graingert changed the title gh-95601: restore support for awaitable objects that are not futures in asyncio.wait and deprecate that support gh-95601: restore support for awaitable objects that are not futures in asyncio.wait Sep 13, 2022
@graingert
Copy link
Contributor Author

@tiran recommended spitting this PR into two, one that restores the functionality removed without deprecation and one that does the deprecation.

@graingert graingert force-pushed the forbid-non-futures-in-asyncio-wait branch from a4c6c1c to a5c5f4a Compare September 13, 2022 06:13
@graingert graingert requested a review from pablogsal September 13, 2022 06:57
@serhiy-storchaka
Copy link
Member

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.

@graingert
Copy link
Contributor Author

graingert commented Sep 14, 2022

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.")
Copy link
Member

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?

Copy link
Contributor Author

@graingert graingert Sep 14, 2022

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

@graingert
Copy link
Contributor Author

@serhiy-storchaka can you re-review this? I'll add the warning if you and @tiran agree it should be added in this PR.

Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

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

I discussed this with @1st1 and a few others at the core dev sprint today, and we're not excited about this. There's definitely no support for trying to wedge this into the 3.11 release at this point.

IIRC @1st1 is planning to add his own response.

@kumaraditya303
Copy link
Contributor

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.

@gvanrossum
Copy link
Member

I think it’s better to start over with a clean slate.

@gvanrossum gvanrossum closed this Oct 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting core review needs backport to 3.11 only security fixes topic-asyncio type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants