This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add @cancellable
decorator, for use on endpoint methods that can be cancelled when clients disconnect
#12583
Closed
+684
−9
Closed
Changes from 17 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
2780bed
Add `@cancellable` decorator, for use on request handlers
1ce7dbf
Improve logging for cancelled requests
0dc4178
Add ability to cancel disconnected requests to `SynapseRequest`
5a9991c
Capture the `Deferred` for request cancellation in `_AsyncResource`
46cdb4b
Respect the `@cancellable` flag for `DirectServe{Html,Json}Resource`s
2326bbf
Respect the `@cancellable` flag for `RestServlet`s and `BaseFederatio…
c3eb1e3
Complain if a federation endpoint has the `@cancellable` flag
62d3b91
Respect the `@cancellable` flag for `ReplicationEndpoint`s
3d89472
Expose the `SynapseRequest` from `FakeChannel` for testing disconnection
2bbad29
Add helper class for testing request cancellation
6720b87
Test the `@cancellable` flag on `RestServlet` methods
92b7b17
Test the `@cancellable` flag on `DirectServe{Html,Json}Resource` methods
d3f75f3
Test the `@cancellable` flag on `ReplicationEndpoint._handle_request`
3544cfd
Fix `make_signed_federation_request` turning empty dicts into `b""`
89cb0f1
Test the `@cancellable` flag on `BaseFederationServlet` methods
342a502
Disable tests for the `@cancellable` flag on `BaseFederationServlet` …
a89fc72
Add newsfile
3f8a59f
Don't trash the logging context when cancelling request processing
08acc0c
Rename to `EndpointCancellationTestCase` to `EndpointCancellationTest…
4976ae5
Add missing docstring for `expected_body` parameter
4e644ea
Improve assertion message when `await_result=False` is forgotten
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add `@cancellable` decorator, for use on endpoint methods that can be cancelled when clients disconnect. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Copyright 2022 The Matrix.org Foundation C.I.C. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 wonder if we should add an explicit
cancellable
parameter toregister_paths
instead.There are a few places where we call
register_paths
manually, with callbacks that don't match the^on_(GET|PUT|POST|DELETE)$
pattern, eg.synapse/synapse/rest/client/room.py
Lines 133 to 138 in 4bc8cb4
There we have the option of either relaxing the validation in the
@cancellable
decorator or adding an explicitcancellable
parameter toregister_paths
.The benefit of relaxing the decorator validation is that it's more obvious that
on_GET_no_state_key
has cancellation enabled: