mirror of https://github.com/zulip/zulip.git
Use a function for stopping/restarting time logging for longpolling.
(imported from commit 11b772deaa126fcc7e7605d467022b22d9e98cb0)
This commit is contained in:
parent
5f28cf8e02
commit
5e22778843
|
@ -15,6 +15,7 @@ import signal
|
|||
import tornado
|
||||
import random
|
||||
import zephyr.lib.stats as stats
|
||||
from zephyr.middleware import async_request_restart
|
||||
|
||||
# The idle timeout used to be a week, but we found that in that
|
||||
# situation, queues from dead browser sessions would grow quite large
|
||||
|
@ -44,7 +45,7 @@ class ClientDescriptor(object):
|
|||
|
||||
def add_event(self, event):
|
||||
if self.current_handler is not None:
|
||||
self.current_handler._request._time_restarted = time.time()
|
||||
async_request_restart(self.current_handler._request)
|
||||
|
||||
self.event_queue.push(event)
|
||||
if self.current_handler is not None:
|
||||
|
|
|
@ -23,6 +23,7 @@ from zephyr.lib.response import json_response
|
|||
from zephyr import tornado_callbacks
|
||||
from zephyr.lib.event_queue import setup_event_queue
|
||||
from zephyr.lib.queue import setup_tornado_rabbitmq
|
||||
from zephyr.middleware import async_request_stop
|
||||
|
||||
if settings.USING_RABBITMQ:
|
||||
from zephyr.lib.queue import queue_client
|
||||
|
@ -227,7 +228,7 @@ class AsyncDjangoHandler(tornado.web.RequestHandler, base.BaseHandler):
|
|||
try:
|
||||
response = callback(request, *callback_args, **callback_kwargs)
|
||||
if response is RespondAsynchronously:
|
||||
request._time_stopped = time.time()
|
||||
async_request_stop(request)
|
||||
return
|
||||
except Exception, e:
|
||||
# If the view raised an exception, run it through exception
|
||||
|
|
|
@ -11,6 +11,12 @@ import time
|
|||
|
||||
logger = logging.getLogger('humbug.requests')
|
||||
|
||||
def async_request_stop(request):
|
||||
request._time_stopped = time.time()
|
||||
|
||||
def async_request_restart(request):
|
||||
request._time_restarted = time.time()
|
||||
|
||||
class LogRequests(object):
|
||||
def process_request(self, request):
|
||||
request._time_started = time.time()
|
||||
|
|
|
@ -9,7 +9,7 @@ from zephyr.decorator import asynchronous, authenticated_api_view, \
|
|||
JsonableError, authenticated_rest_api_view, REQ
|
||||
|
||||
from zephyr.lib.response import json_response, json_success, json_error
|
||||
|
||||
from zephyr.middleware import async_request_restart
|
||||
from zephyr.tornado_callbacks import \
|
||||
get_user_pointer, fetch_stream_messages, fetch_user_messages, \
|
||||
add_stream_receive_callback, add_user_receive_callback, \
|
||||
|
@ -155,7 +155,7 @@ def get_updates_backend(request, user_profile, handler, client_id,
|
|||
# response.
|
||||
|
||||
def cb(**cb_kwargs):
|
||||
request._time_restarted = time.time()
|
||||
async_request_restart(request)
|
||||
if handler.request.connection.stream.closed():
|
||||
return
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue