Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Add documentation for cancellation of request processing #12761

Merged
merged 5 commits into from
May 18, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Apply suggestions from code review
  • Loading branch information
Sean Quah committed May 18, 2022
commit 482f4dd82d238368c739bd3616aa698109fcce6c
5 changes: 3 additions & 2 deletions docs/development/synapse_architecture/cancellation.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ can cancel request processing for select endpoints marked with the

Synapse makes use of Twisted's `Deferred.cancel()` feature to make
cancellation work. The `@cancellable` decorator does nothing by itself
and merely acts as a flag.
and merely acts as a flag, signalling to developers and other code alike
that a method can be cancelled.

## Enabling cancellation for an endpoint
1. Check that the endpoint method, and any `async` functions in its call
Expand Down Expand Up @@ -50,7 +51,7 @@ request = defer.ensureDeferred(on_GET())
When a client disconnects early, Synapse checks for the presence of the
`@cancellable` decorator on `on_GET`. Since `on_GET` is cancellable,
`Deferred.cancel()` is called on the `Deferred` from
`defer.ensureDeferred`, `request`. Twisted knows which `Deferred`
`defer.ensureDeferred`, ie. `request`. Twisted knows which `Deferred`
`request` is waiting on and passes the `cancel()` call on to `d`.

The `Deferred` being waited on, `d`, may have its own handling for
Expand Down