summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-06-18 16:15:10 +0100
committerErik Johnston <erik@matrix.org>2015-06-18 16:15:10 +0100
commit73513ececce51427971d49f0d55bfa76dafc391e (patch)
tree46cc18dbf1f0b452a5a5a0df8c13b777d041015c /synapse
parentDon't bother proxying lookups on _NotificationListener to underlying deferred (diff)
downloadsynapse-73513ececce51427971d49f0d55bfa76dafc391e.tar.xz
Documentation
Diffstat (limited to '')
-rw-r--r--synapse/notifier.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/synapse/notifier.py b/synapse/notifier.py
index 053475a2f5..5475ee36ca 100644
--- a/synapse/notifier.py
+++ b/synapse/notifier.py
@@ -305,10 +305,13 @@ class Notifier(object):
 
         result = None
         if timeout:
-            listener = None
-            timer = self.clock.call_later(
-                timeout/1000., lambda: listener.deferred.cancel()
-            )
+            listener = None  # Will be set to a _NotificationListener that
+                             # we'll be waiting on. Allows us to cancel it.
+
+            def timed_out():
+                if listener:
+                    listener.deferred.cancel()
+            timer = self.clock.call_later(timeout/1000., timed_out)
 
             prev_token = from_token
             while not result:
@@ -319,6 +322,10 @@ class Notifier(object):
                     if result:
                         break
 
+                    # Now we wait for the _NotifierUserStream to be told there
+                    # is a new token.
+                    # We need to supply the token we supplied to callback so
+                    # that we don't miss any current_token updates.
                     prev_token = current_token
                     listener = user_stream.new_listener(prev_token)
                     yield listener.deferred