diff options
author | Sean Quah <8349537+squahtx@users.noreply.github.com> | 2022-04-05 15:43:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-05 15:43:52 +0100 |
commit | 800ba87cc881856adae19ec40485578356398639 (patch) | |
tree | cb19370283b7def590239b507c5dc5c72e39af8a /synapse/handlers/presence.py | |
parent | Merge branch 'master' into develop (diff) | |
download | synapse-800ba87cc881856adae19ec40485578356398639.tar.xz |
Refactor and convert `Linearizer` to async (#12357)
Refactor and convert `Linearizer` to async. This makes a `Linearizer` cancellation bug easier to fix. Also refactor to use an async context manager, which eliminates an unlikely footgun where code that doesn't immediately use the context manager could forget to release the lock. Signed-off-by: Sean Quah <seanq@element.io>
Diffstat (limited to 'synapse/handlers/presence.py')
-rw-r--r-- | synapse/handlers/presence.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/synapse/handlers/presence.py b/synapse/handlers/presence.py index dace31d87e..209a4b0e52 100644 --- a/synapse/handlers/presence.py +++ b/synapse/handlers/presence.py @@ -1030,7 +1030,7 @@ class PresenceHandler(BasePresenceHandler): is_syncing: Whether or not the user is now syncing sync_time_msec: Time in ms when the user was last syncing """ - with (await self.external_sync_linearizer.queue(process_id)): + async with self.external_sync_linearizer.queue(process_id): prev_state = await self.current_state_for_user(user_id) process_presence = self.external_process_to_current_syncs.setdefault( @@ -1071,7 +1071,7 @@ class PresenceHandler(BasePresenceHandler): Used when the process has stopped/disappeared. """ - with (await self.external_sync_linearizer.queue(process_id)): + async with self.external_sync_linearizer.queue(process_id): process_presence = self.external_process_to_current_syncs.pop( process_id, set() ) |