tornado: Move setup_tornado_rabbitmq to application.py

This commit is contained in:
Umair Khan
2017-07-21 09:55:25 +05:00
parent 4ea45743d0
commit 758dbec9e2
3 changed files with 12 additions and 9 deletions

View File

@@ -9,7 +9,6 @@ import ujson
import random
import time
import threading
import atexit
from collections import defaultdict
from zerver.lib.utils import statsd
@@ -291,12 +290,6 @@ def get_queue_client():
return queue_client
def setup_tornado_rabbitmq():
# type: () -> None
# When tornado is shut down, disconnect cleanly from rabbitmq
if settings.USING_RABBITMQ:
atexit.register(lambda: queue_client.close())
# We using a simple lock to prevent multiple RabbitMQ messages being
# sent to the SimpleQueueClient at the same time; this is a workaround
# for an issue with the pika BlockingConnection where using

View File

@@ -17,8 +17,8 @@ from tornado.log import app_log
from typing import Callable
from zerver.lib.debug import interactive_debug_listen
from zerver.lib.queue import setup_tornado_rabbitmq
from zerver.tornado.application import create_tornado_application
from zerver.tornado.application import create_tornado_application, \
setup_tornado_rabbitmq
from zerver.tornado.event_queue import add_client_gc_hook, \
missedmessage_hook, process_notification, setup_event_queue
from zerver.tornado.socket import respond_send_message

View File

@@ -1,13 +1,23 @@
from __future__ import absolute_import
from __future__ import print_function
import atexit
from django.conf import settings
from zerver.tornado.handlers import AsyncDjangoHandler
from zerver.tornado.socket import get_sockjs_router
from zerver.lib.queue import get_queue_client
import tornado.web
def setup_tornado_rabbitmq():
# type: () -> None
# When tornado is shut down, disconnect cleanly from rabbitmq
if settings.USING_RABBITMQ:
queue_client = get_queue_client()
atexit.register(lambda: queue_client.close())
def create_tornado_application():
# type: () -> tornado.web.Application
urls = (r"/notify_tornado",