diff options
author | Erik Johnston <erik@matrix.org> | 2014-10-17 18:56:42 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2014-10-17 18:56:42 +0100 |
commit | 5ffe5ab43fa090111a0141b04ce6342172f60724 (patch) | |
tree | 45af4a0c2fdbb3c89853645cafe1440b13c6d3f4 /synapse/rest/events.py | |
parent | Finish implementing the new join dance. (diff) | |
download | synapse-5ffe5ab43fa090111a0141b04ce6342172f60724.tar.xz |
Use state groups to get current state. Make join dance actually work.
Diffstat (limited to 'synapse/rest/events.py')
-rw-r--r-- | synapse/rest/events.py | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/synapse/rest/events.py b/synapse/rest/events.py index 097195d7cc..92ff5e5ca7 100644 --- a/synapse/rest/events.py +++ b/synapse/rest/events.py @@ -20,6 +20,12 @@ from synapse.api.errors import SynapseError from synapse.streams.config import PaginationConfig from synapse.rest.base import RestServlet, client_path_pattern +import logging + + +logger = logging.getLogger(__name__) + + class EventStreamRestServlet(RestServlet): PATTERN = client_path_pattern("/events$") @@ -29,18 +35,22 @@ class EventStreamRestServlet(RestServlet): @defer.inlineCallbacks def on_GET(self, request): auth_user = yield self.auth.get_user_by_req(request) - - handler = self.handlers.event_stream_handler - pagin_config = PaginationConfig.from_request(request) - timeout = EventStreamRestServlet.DEFAULT_LONGPOLL_TIME_MS - if "timeout" in request.args: - try: - timeout = int(request.args["timeout"][0]) - except ValueError: - raise SynapseError(400, "timeout must be in milliseconds.") - - chunk = yield handler.get_stream(auth_user.to_string(), pagin_config, - timeout=timeout) + try: + handler = self.handlers.event_stream_handler + pagin_config = PaginationConfig.from_request(request) + timeout = EventStreamRestServlet.DEFAULT_LONGPOLL_TIME_MS + if "timeout" in request.args: + try: + timeout = int(request.args["timeout"][0]) + except ValueError: + raise SynapseError(400, "timeout must be in milliseconds.") + + chunk = yield handler.get_stream( + auth_user.to_string(), pagin_config, timeout=timeout + ) + except: + logger.exception("Event stream failed") + raise defer.returnValue((200, chunk)) |