mirror of https://github.com/zulip/zulip.git
tornado: Make _request an attribute on AsyncDjangoHandler.
For the same reason as `handler_id` has, we define `_request` as an attribute. Note that the name `request` is already taken. Signed-off-by: Zixuan James Li <p359101898@gmail.com>
This commit is contained in:
parent
56e1f3b725
commit
a9029c68ea
|
@ -182,6 +182,7 @@ class ClientDescriptor:
|
||||||
def add_event(self, event: Mapping[str, Any]) -> None:
|
def add_event(self, event: Mapping[str, Any]) -> None:
|
||||||
if self.current_handler_id is not None:
|
if self.current_handler_id is not None:
|
||||||
handler = get_handler_by_id(self.current_handler_id)
|
handler = get_handler_by_id(self.current_handler_id)
|
||||||
|
assert handler._request is not None
|
||||||
async_request_timer_restart(handler._request)
|
async_request_timer_restart(handler._request)
|
||||||
|
|
||||||
self.event_queue.push(event)
|
self.event_queue.push(event)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import logging
|
import logging
|
||||||
import urllib
|
import urllib
|
||||||
from typing import Any, Dict, List
|
from typing import Any, Dict, List, Optional
|
||||||
|
|
||||||
import tornado.web
|
import tornado.web
|
||||||
from asgiref.sync import sync_to_async
|
from asgiref.sync import sync_to_async
|
||||||
|
@ -54,6 +54,7 @@ def finish_handler(
|
||||||
# get_events request has supplanted this request)
|
# get_events request has supplanted this request)
|
||||||
handler = get_handler_by_id(handler_id)
|
handler = get_handler_by_id(handler_id)
|
||||||
request = handler._request
|
request = handler._request
|
||||||
|
assert request is not None
|
||||||
async_request_timer_restart(request)
|
async_request_timer_restart(request)
|
||||||
log_data = RequestNotes.get_notes(request).log_data
|
log_data = RequestNotes.get_notes(request).log_data
|
||||||
assert log_data is not None
|
assert log_data is not None
|
||||||
|
@ -92,6 +93,8 @@ class AsyncDjangoHandler(tornado.web.RequestHandler, base.BaseHandler):
|
||||||
# be cleared when the handler finishes its response
|
# be cleared when the handler finishes its response
|
||||||
self.handler_id = allocate_handler_id(self)
|
self.handler_id = allocate_handler_id(self)
|
||||||
|
|
||||||
|
self._request: Optional[HttpRequest] = None
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
descriptor = get_descriptor_by_handler_id(self.handler_id)
|
descriptor = get_descriptor_by_handler_id(self.handler_id)
|
||||||
return f"AsyncDjangoHandler<{self.handler_id}, {descriptor}>"
|
return f"AsyncDjangoHandler<{self.handler_id}, {descriptor}>"
|
||||||
|
|
Loading…
Reference in New Issue