mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-08-06 04:54:15 -04:00
Capture the Deferred
for request cancellation in _AsyncResource
(#12694)
All async request processing goes through `_AsyncResource`, so this is the only place where a `Deferred` needs to be captured for cancellation. Unfortunately, the same isn't true for determining whether a request can be cancelled. Each of `RestServlet`, `BaseFederationServlet`, `DirectServe{Html,Json}Resource` and `ReplicationEndpoint` have different wrappers around the method doing the request handling and they all need to be handled separately. Signed-off-by: Sean Quah <seanq@element.io>
This commit is contained in:
parent
29f06704b8
commit
c997bfb926
3 changed files with 9 additions and 5 deletions
|
@ -92,11 +92,12 @@ class SynapseRequest(Request):
|
|||
# we can't yet create the logcontext, as we don't know the method.
|
||||
self.logcontext: Optional[LoggingContext] = None
|
||||
|
||||
# The `Deferred` to cancel if the client disconnects early. Expected to be set
|
||||
# by `Resource.render`.
|
||||
# The `Deferred` to cancel if the client disconnects early and
|
||||
# `is_render_cancellable` is set. Expected to be set by `Resource.render`.
|
||||
self.render_deferred: Optional["Deferred[None]"] = None
|
||||
# A boolean indicating whether `_render_deferred` should be cancelled if the
|
||||
# client disconnects early. Expected to be set during `Resource.render`.
|
||||
# A boolean indicating whether `render_deferred` should be cancelled if the
|
||||
# client disconnects early. Expected to be set by the coroutine started by
|
||||
# `Resource.render`, if rendering is asynchronous.
|
||||
self.is_render_cancellable = False
|
||||
|
||||
global _next_request_seq
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue