From 6df83555cc98ff7f04e1ccf9a648f2b5cb24298e Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Wed, 13 Aug 2014 17:13:26 +0100 Subject: Handle a potential race in the notifier when calling get_events_for which resulted in an uncaught KeyError --- synapse/api/notifier.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'synapse') 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 -- cgit 1.4.1