Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
tornado: Make _request an attribute on AsyncDjangoHandler.
Zixuan James Lia9029c68eadb
diff --git a/zerver/tornado/event_queue.py b/zerver/tornado/event_queue.pyindex 057715fa3da..55db6879569 100644--- a/zerver/tornado/event_queue.py+++ b/zerver/tornado/event_queue.py@@ -182,6 +182,7 @@ class ClientDescriptor:def add_event(self, event: Mapping[str, Any]) -> None:if self.current_handler_id is not None:handler = get_handler_by_id(self.current_handler_id)+ assert handler._request is not Noneasync_request_timer_restart(handler._request)self.event_queue.push(event)diff --git a/zerver/tornado/handlers.py b/zerver/tornado/handlers.pyindex bf341cfdc27..ce175f4a37a 100644--- a/zerver/tornado/handlers.py+++ b/zerver/tornado/handlers.py@@ -1,6 +1,6 @@import loggingimport urllib-from typing import Any, Dict, List+from typing import Any, Dict, List, Optionalimport tornado.webfrom asgiref.sync import sync_to_async@@ -54,6 +54,7 @@ def finish_handler(# get_events request has supplanted this request)handler = get_handler_by_id(handler_id)request = handler._request+ assert request is not Noneasync_request_timer_restart(request)log_data = RequestNotes.get_notes(request).log_dataassert log_data is not None@@ -92,6 +93,8 @@ class AsyncDjangoHandler(tornado.web.RequestHandler, base.BaseHandler):# be cleared when the handler finishes its responseself.handler_id = allocate_handler_id(self)+ self._request: Optional[HttpRequest] = None+def __repr__(self) -> str:descriptor = get_descriptor_by_handler_id(self.handler_id)return f"AsyncDjangoHandler<{self.handler_id}, {descriptor}>"