diff options
author | Erik Johnston <erik@matrix.org> | 2017-10-25 15:21:08 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2017-10-25 15:21:08 +0100 |
commit | 2a7e9faeec9af8723b9613fef3b3059b1fe777f5 (patch) | |
tree | 53d837f7fdbc2f1ab6ed7c4b1dc797efc60574ac /synapse/handlers | |
parent | Add logging and fix log contexts for publicRooms (diff) | |
download | synapse-2a7e9faeec9af8723b9613fef3b3059b1fe777f5.tar.xz |
Do logcontexts outside ResponseCache
Diffstat (limited to 'synapse/handlers')
-rw-r--r-- | synapse/handlers/room_list.py | 7 | ||||
-rw-r--r-- | synapse/handlers/sync.py | 6 |
2 files changed, 8 insertions, 5 deletions
diff --git a/synapse/handlers/room_list.py b/synapse/handlers/room_list.py index ae7c611170..5a47254b56 100644 --- a/synapse/handlers/room_list.py +++ b/synapse/handlers/room_list.py @@ -20,6 +20,7 @@ from ._base import BaseHandler from synapse.api.constants import ( EventTypes, JoinRules, ) +from synapse.util.logcontext import make_deferred_yieldable, preserve_fn from synapse.util.async import concurrently_execute from synapse.util.caches.descriptors import cachedInlineCallbacks from synapse.util.caches.response_cache import ResponseCache @@ -81,11 +82,13 @@ class RoomListHandler(BaseHandler): logger.info("No cached result, calculating one.") result = self.response_cache.set( key, - self._get_public_room_list( + preserve_fn(self._get_public_room_list)( limit, since_token, network_tuple=network_tuple ) ) - return result + else: + logger.info("Using cached result.") + return make_deferred_yieldable(result) @defer.inlineCallbacks def _get_public_room_list(self, limit=None, since_token=None, diff --git a/synapse/handlers/sync.py b/synapse/handlers/sync.py index 219529936f..b12988f3c9 100644 --- a/synapse/handlers/sync.py +++ b/synapse/handlers/sync.py @@ -15,7 +15,7 @@ from synapse.api.constants import Membership, EventTypes from synapse.util.async import concurrently_execute -from synapse.util.logcontext import LoggingContext +from synapse.util.logcontext import LoggingContext, make_deferred_yieldable, preserve_fn from synapse.util.metrics import Measure, measure_func from synapse.util.caches.response_cache import ResponseCache from synapse.push.clientformat import format_push_rules_for_user @@ -184,11 +184,11 @@ class SyncHandler(object): if not result: result = self.response_cache.set( sync_config.request_key, - self._wait_for_sync_for_user( + preserve_fn(self._wait_for_sync_for_user)( sync_config, since_token, timeout, full_state ) ) - return result + return make_deferred_yieldable(result) @defer.inlineCallbacks def _wait_for_sync_for_user(self, sync_config, since_token, timeout, |