diff options
author | Mark Haines <mark.haines@matrix.org> | 2015-05-13 15:42:13 +0100 |
---|---|---|
committer | Mark Haines <mark.haines@matrix.org> | 2015-05-13 15:42:13 +0100 |
commit | 9af432257da39385ce03c846b3c76f7fc7778ff0 (patch) | |
tree | 94d397cdbd0a109342230bf494b5619703478426 | |
parent | Don't bother checking for new events from a source if the stream token hasn't... (diff) | |
download | synapse-9af432257da39385ce03c846b3c76f7fc7778ff0.tar.xz |
Don't set a timer if there's already a result to return
Diffstat (limited to '')
-rw-r--r-- | synapse/notifier.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/synapse/notifier.py b/synapse/notifier.py index d2fefea756..6fcb7767a0 100644 --- a/synapse/notifier.py +++ b/synapse/notifier.py @@ -82,9 +82,10 @@ class _NotifierUserStream(object): self.current_token = self.current_token.copy_and_replace( stream_key, stream_id ) - for listener in self.listeners: + listeners = self.listeners + self.listeners = set() + for listener in listeners: listener.notify(self.current_token) - self.listeners.clear() def remove(self, notifier): """ Remove this listener from all the indexes in the Notifier @@ -202,7 +203,7 @@ class Notifier(object): user_streams = room_user_streams.copy() for user in extra_users: - user_stream = self.user_to_user_stream.get(user) + user_stream = self.user_to_user_stream.get(str(user)) if user_stream is not None: user_streams.add(user_stream) @@ -288,12 +289,18 @@ class Notifier(object): timer = [None] + if result: + user_stream.listeners.discard(listener[0]) + defer.returnValue(result) + return + if timeout: timed_out = [False] def _timeout_listener(): timed_out[0] = True timer[0] = None + user_stream.listeners.discard(listener[0]) listener[0].notify(from_token) # We create multiple notification listeners so we have to manage |