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

Fix cancellation tests with new Twisted. #17906

Merged
merged 5 commits into from
Nov 7, 2024
Merged

Conversation

erikjohnston
Copy link
Member

@erikjohnston erikjohnston commented Nov 6, 2024

The latest Twisted release changed how they implemented __await__ on deferreds, which broke the machinery we used to test cancellation.

This PR changes things a bit to instead patch the __await__ method, which is a stable API. This mostly doesn't change the core logic, except for fixing two bugs:

  • We previously did not intercept all await points
  • After cancellation we now need to not only unblock currently blocked await points, but also make sure we don't block any future await points.

c.f. twisted/twisted#12226

The latest Twisted release changed how they implemented `__await__` on
deferreds, which broke the machinery we used to test cancellation.

This PR changes things a bit to instead patch the `__await__` method,
which is a stable API. This mostly doesn't change the core logic, except
for fixing two bugs:
  - We previously did not intercept all await points
  - After cancellation we now need to not only unblock currently blocked
    await points, but also make sure we don't block any future await
    points.

c.f. twisted/twisted#12226
@erikjohnston erikjohnston marked this pull request as ready for review November 6, 2024 16:48
@erikjohnston erikjohnston requested a review from a team as a code owner November 6, 2024 16:48
Copy link
Member

@devonh devonh left a comment

Choose a reason for hiding this comment

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

Just a couple small things.
Otherwise I've looked through this thoroughly with reference to the mentioned twisted PR and I believe the logic is sound.

tests/http/server/_base.py Outdated Show resolved Hide resolved
tests/http/server/_base.py Outdated Show resolved Hide resolved
erikjohnston added a commit that referenced this pull request Nov 7, 2024
Co-authored-by: Devon Hudson <devon.dmytro@gmail.com>
@devonh devonh merged commit d0fc1e9 into develop Nov 7, 2024
33 checks passed
@devonh devonh deleted the erikj/twisted_patch branch November 7, 2024 15:26
erikjohnston added a commit that referenced this pull request Nov 7, 2024
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.

2 participants