Merge pull request #1061 from matrix-org/erikj/linearize_resolution

Linearize state resolution to help caches
This commit is contained in:
Erik Johnston 2016-09-01 15:58:19 +01:00 committed by GitHub
commit c1c38da586

View file

@ -23,6 +23,7 @@ from synapse.api.constants import EventTypes
from synapse.api.errors import AuthError
from synapse.api.auth import AuthEventTypes
from synapse.events.snapshot import EventContext
from synapse.util.async import Linearizer
from collections import namedtuple
@ -84,6 +85,7 @@ class StateHandler(object):
# dict of set of event_ids -> _StateCacheEntry.
self._state_cache = None
self.resolve_linearizer = Linearizer()
def start_caching(self):
logger.debug("start_caching")
@ -283,6 +285,7 @@ class StateHandler(object):
state_group=name,
))
with (yield self.resolve_linearizer.queue(group_names)):
if self._state_cache is not None:
cache = self._state_cache.get(group_names, None)
if cache: