mirror of https://github.com/zulip/zulip.git
Allocate handler ids in AsyncDjangoHandler setup process.
This commit is contained in:
parent
ae760a351e
commit
ea6211c041
|
@ -10,9 +10,9 @@ def get_handler_by_id(handler_id):
|
|||
def allocate_handler_id(handler):
|
||||
global current_handler_id
|
||||
handlers[current_handler_id] = handler
|
||||
ret = current_handler_id
|
||||
handler.handler_id = current_handler_id
|
||||
current_handler_id += 1
|
||||
return ret
|
||||
return handler.handler_id
|
||||
|
||||
def finish_handler(handler_id, event_queue_id, contents, apply_markdown):
|
||||
err_msg = "Got error finishing handler for queue %s" % (event_queue_id,)
|
||||
|
|
|
@ -12,6 +12,8 @@ from zerver.lib.actions import (
|
|||
get_display_recipient,
|
||||
)
|
||||
|
||||
from zerver.lib.handlers import allocate_handler_id
|
||||
|
||||
from zerver.models import (
|
||||
get_realm,
|
||||
get_stream,
|
||||
|
@ -162,6 +164,7 @@ class DummyHandler(object):
|
|||
def __init__(self, assert_callback):
|
||||
self.assert_callback = assert_callback
|
||||
self.request = DummyTornadoRequest()
|
||||
allocate_handler_id(self)
|
||||
|
||||
# Mocks RequestHandler.async_callback, which wraps a callback to
|
||||
# handle exceptions. We return the callback as-is.
|
||||
|
|
|
@ -22,6 +22,7 @@ from zerver.lib.debug import interactive_debug_listen
|
|||
from zerver.lib.response import json_response
|
||||
from zerver.lib.event_queue import process_notification, missedmessage_hook
|
||||
from zerver.lib.event_queue import setup_event_queue, add_client_gc_hook
|
||||
from zerver.lib.handlers import allocate_handler_id
|
||||
from zerver.lib.queue import setup_tornado_rabbitmq
|
||||
from zerver.lib.socket import get_sockjs_router, respond_send_message
|
||||
from zerver.middleware import async_request_stop
|
||||
|
@ -142,6 +143,7 @@ class AsyncDjangoHandler(tornado.web.RequestHandler, base.BaseHandler):
|
|||
self.initLock.release()
|
||||
self._auto_finish = False
|
||||
self.client_descriptor = None
|
||||
allocate_handler_id(self)
|
||||
|
||||
def get(self):
|
||||
from tornado.wsgi import WSGIContainer
|
||||
|
|
|
@ -42,7 +42,7 @@ def json_get_events(request, user_profile):
|
|||
|
||||
@asynchronous
|
||||
@has_request_variables
|
||||
def get_events_backend(request, user_profile, handler = None,
|
||||
def get_events_backend(request, user_profile, handler,
|
||||
user_client = REQ(converter=get_client, default=None),
|
||||
last_event_id = REQ(converter=int, default=None),
|
||||
queue_id = REQ(default=None),
|
||||
|
@ -55,11 +55,10 @@ def get_events_backend(request, user_profile, handler = None,
|
|||
if user_client is None:
|
||||
user_client = request.client
|
||||
|
||||
handler_id = allocate_handler_id(handler)
|
||||
(result, log_data) = fetch_events(
|
||||
user_profile.id, user_profile.realm_id, user_profile.email, queue_id,
|
||||
last_event_id, event_types, user_client, apply_markdown, all_public_streams,
|
||||
lifespan_secs, narrow, dont_block, handler_id)
|
||||
lifespan_secs, narrow, dont_block, handler.handler_id)
|
||||
request._log_data['extra'] = log_data
|
||||
if result == RespondAsynchronously:
|
||||
handler._request = request
|
||||
|
|
Loading…
Reference in New Issue