Skip to content

PEP 789: Preventing task-cancellation bugs by limiting yield in async generators#3782

Merged
njsmith merged 17 commits intopython:mainfrom
Zac-HD:preventing-cancel-bugs
Jun 4, 2024
Merged

PEP 789: Preventing task-cancellation bugs by limiting yield in async generators#3782
njsmith merged 17 commits intopython:mainfrom
Zac-HD:preventing-cancel-bugs

Conversation

@Zac-HD
Copy link
Contributor

@Zac-HD Zac-HD commented May 15, 2024

I had so much fun working on PEP-678 that I'm back again, this time with a proposal to mitigate an extremely nasty interaction between async generators and 'cancel scope' context managers (such as asyncio.timeout and asyncio.TaskGroup).

It's co-authored with @njsmith based on this discuss thread, and I'm aiming to discuss this at the language summit I'm posting this draft despite a few open questions and placeholders for a worked example.

and... if it's not too cheeky, can I ask @python/pep-editors to grant this PEP number 789? It'd be a cute sequel to my last 😁
(huh, that's the tag suggested in PEP 1, but it's not hyperlinked. @JelleZijlstra then?)


📚 Documentation preview 📚: https://pep-previews--3782.org.readthedocs.build/pep-0789/

@Zac-HD Zac-HD requested a review from a team as a code owner May 15, 2024 03:12
@Rosuav
Copy link
Contributor

Rosuav commented May 15, 2024

Hmm, the docs build failed, but the output is quite hard to read. The actual error is hidden away and you have to scroll to the right to fix it - but there's no scroll bar. This is really an infrastructure note rather than a comment about this PR specifically (I'm sure you're already aware of it and working on that); how hard would it be to catch docutils.utils.SystemMessage and print out the message in a more useful manner?

@Zac-HD Zac-HD force-pushed the preventing-cancel-bugs branch from 4258809 to f80e2f2 Compare May 15, 2024 03:49
Copy link
Member

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

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

PEP number is assigned, here's a few comments on the text.

@AlexWaygood AlexWaygood changed the title PEP 9999: Preventing task-cancellation bugs by limiting yield in async generators PEP 789: Preventing task-cancellation bugs by limiting yield in async generators May 15, 2024
@hugovk
Copy link
Member

hugovk commented May 15, 2024

Please add @njsmith to the CODEOWNERS file.

There's also a "New PEP" checklist at https://github.com/python/peps/blob/main/.github/PULL_REQUEST_TEMPLATE/Add%20a%20new%20PEP.md you could copy into the OP.

@Zac-HD Zac-HD requested a review from AA-Turner as a code owner May 15, 2024 15:38
@Zac-HD Zac-HD force-pushed the preventing-cancel-bugs branch from 2408999 to d40352a Compare May 15, 2024 17:58
@carljm
Copy link
Member

carljm commented May 15, 2024

You've gotten PEP numbers 678 and 789, well planned. Probably you should just reserve 890 now.

Zac-HD added 2 commits May 27, 2024 01:02
For expedience I'm using sphinxcontrib-mermaid here; we can easily embed .png versions before merging if preferred.
@Zac-HD
Copy link
Contributor Author

Zac-HD commented May 31, 2024

@JelleZijlstra I'm happy to call this draft substantively done, and merge it + open a Discuss thread.

Based on discussions at the PyCon language summit and sprints, my impression is that the PEP is likely to be accepted if an implementation with satisfactory performance is available. Next steps are therefore to produce such an implementation! A solid prototype will give us more basis to disucss the remaining todo items, as well as whether and when to use it in the standard library, so I anticipate a quiet period for a few months.

@JelleZijlstra
Copy link
Member

I'm happy with the text, but @njsmith as the sponsor should also confirm that they're OK with merging this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants