diff options
author | Sean Quah <8349537+squahtx@users.noreply.github.com> | 2022-05-09 12:31:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-09 12:31:14 +0100 |
commit | a00462dd9927558532b030593f8914ade53b7214 (patch) | |
tree | d15933417e46d7b451298238b39bced69ebffa0b /synapse/handlers/account_validity.py | |
parent | Fix mypy against latest pillow stubs (#12671) (diff) | |
download | synapse-a00462dd9927558532b030593f8914ade53b7214.tar.xz |
Implement cancellation support/protection for module callbacks (#12568)
There's no guarantee that module callbacks will handle cancellation appropriately. Protect module callbacks with read semantics from cancellation and avoid swallowing `CancelledError`s that arise. Other module callbacks, such as the `on_*` callbacks, are presumed to live on code paths that involve writes and aren't cancellation-friendly. These module callbacks have been left alone. Signed-off-by: Sean Quah <seanq@element.io>
Diffstat (limited to 'synapse/handlers/account_validity.py')
-rw-r--r-- | synapse/handlers/account_validity.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/synapse/handlers/account_validity.py b/synapse/handlers/account_validity.py index 05a138410e..33e45e3a11 100644 --- a/synapse/handlers/account_validity.py +++ b/synapse/handlers/account_validity.py @@ -23,6 +23,7 @@ from synapse.api.errors import AuthError, StoreError, SynapseError from synapse.metrics.background_process_metrics import wrap_as_background_process from synapse.types import UserID from synapse.util import stringutils +from synapse.util.async_helpers import delay_cancellation if TYPE_CHECKING: from synapse.server import HomeServer @@ -150,7 +151,7 @@ class AccountValidityHandler: Whether the user has expired. """ for callback in self._is_user_expired_callbacks: - expired = await callback(user_id) + expired = await delay_cancellation(callback(user_id)) if expired is not None: return expired |