Skip to content
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

New asyncio rule: ban asyncio.shield #320

Open
jakkdl opened this issue Nov 17, 2024 · 1 comment
Open

New asyncio rule: ban asyncio.shield #320

jakkdl opened this issue Nov 17, 2024 · 1 comment
Labels
enhancement New feature or request postponed Low priority, blocked, or similar.

Comments

@jakkdl
Copy link
Member

jakkdl commented Nov 17, 2024

https://docs.python.org/3/library/asyncio-task.html#asyncio.shield has the double footgun of #319 and having to reroute the shielded task to a different context where it can be properly monitored for completion of errors. If you're already doing the latter, you might as well send the coroutine directly and you will have fewer problems handling the Task/Future.
Inspired by @graingert

Implementation would be trivial, most of the work would be writing documentation that explains the issue and how to resolve it.

@jakkdl jakkdl added the enhancement New feature or request label Nov 17, 2024
@Zac-HD
Copy link
Member

Zac-HD commented Nov 17, 2024

I'm a little dubious about the value of this rule in addition to #319; it basically amounts to "we think asyncio's cancellation system is too hard to use correctly". Which, yeah, I do; but given that the user hasn't chosen to migrate to anyio I'm not convinced that we're offering a good safety-to-noise ratio.

Can you say more about what we'd be recommending instead, and why that's better (and a better use of developer time than moving to anyio)?

@jakkdl jakkdl added the postponed Low priority, blocked, or similar. label Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request postponed Low priority, blocked, or similar.
Projects
None yet
Development

No branches or pull requests

2 participants