summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2014-08-13 17:13:26 +0100
committerErik Johnston <erik@matrix.org>2014-08-13 17:13:26 +0100
commit6df83555cc98ff7f04e1ccf9a648f2b5cb24298e (patch)
tree8785ef1b1e36e3ac5f357428b4eb84cb3a7d9981 /synapse
parentStore public room id > alias mappings. (diff)
downloadsynapse-6df83555cc98ff7f04e1ccf9a648f2b5cb24298e.tar.xz
Handle a potential race in the notifier when calling get_events_for which resulted in an uncaught KeyError
Diffstat (limited to 'synapse')
-rw-r--r--synapse/api/notifier.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/synapse/api/notifier.py b/synapse/api/notifier.py
index 22d2914d38..105a11401b 100644
--- a/synapse/api/notifier.py
+++ b/synapse/api/notifier.py
@@ -166,9 +166,13 @@ class Notifier(object):
         """
         logger.debug("%s is listening for events.", user_id)
 
-        if len(self.stored_event_listeners[user_id][stream_id]["chunk"]) > 0:
-            logger.debug("%s returning existing chunk.", user_id)
-            return self.stored_event_listeners[user_id][stream_id]
+        try:
+            streams = self.stored_event_listeners[user_id][stream_id]["chunk"]
+            if streams:
+                logger.debug("%s returning existing chunk.", user_id)
+                return streams
+        except KeyError:
+            return None
 
         reactor.callLater(
             (timeout / 1000.0), self._timeout, user_id, stream_id