From df6db5c8025e67c410a60994ac87eb39d842af30 Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Wed, 13 May 2015 15:08:24 +0100 Subject: [PATCH] Don't bother checking for new events from a source if the stream token hasn't advanced for that source --- synapse/notifier.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/synapse/notifier.py b/synapse/notifier.py index 4d10c05038..d2fefea756 100644 --- a/synapse/notifier.py +++ b/synapse/notifier.py @@ -294,7 +294,7 @@ class Notifier(object): def _timeout_listener(): timed_out[0] = True timer[0] = None - listener[0].notify(user_stream) + listener[0].notify(from_token) # We create multiple notification listeners so we have to manage # canceling the timeout ourselves. @@ -329,11 +329,15 @@ class Notifier(object): limit = pagination_config.limit @defer.inlineCallbacks - def check_for_updates(start_token, end_token): + def check_for_updates(before_token, after_token): events = [] end_token = from_token for name, source in self.event_sources.sources.items(): keyname = "%s_key" % name + before_id = getattr(before_token, keyname) + after_id = getattr(after_token, keyname) + if before_id == after_id: + continue stuff, new_key = yield source.get_new_events_for_user( user, getattr(from_token, keyname), limit, )