mirror of
https://github.com/zulip/zulip.git
synced 2025-11-16 11:52:01 +00:00
tornado: Move setup_tornado_rabbitmq to application.py
This commit is contained in:
@@ -9,7 +9,6 @@ import ujson
|
|||||||
import random
|
import random
|
||||||
import time
|
import time
|
||||||
import threading
|
import threading
|
||||||
import atexit
|
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
from zerver.lib.utils import statsd
|
from zerver.lib.utils import statsd
|
||||||
@@ -291,12 +290,6 @@ def get_queue_client():
|
|||||||
|
|
||||||
return 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
|
# We using a simple lock to prevent multiple RabbitMQ messages being
|
||||||
# sent to the SimpleQueueClient at the same time; this is a workaround
|
# sent to the SimpleQueueClient at the same time; this is a workaround
|
||||||
# for an issue with the pika BlockingConnection where using
|
# for an issue with the pika BlockingConnection where using
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ from tornado.log import app_log
|
|||||||
from typing import Callable
|
from typing import Callable
|
||||||
|
|
||||||
from zerver.lib.debug import interactive_debug_listen
|
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, \
|
from zerver.tornado.event_queue import add_client_gc_hook, \
|
||||||
missedmessage_hook, process_notification, setup_event_queue
|
missedmessage_hook, process_notification, setup_event_queue
|
||||||
from zerver.tornado.socket import respond_send_message
|
from zerver.tornado.socket import respond_send_message
|
||||||
|
|||||||
@@ -1,13 +1,23 @@
|
|||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
|
import atexit
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
from zerver.tornado.handlers import AsyncDjangoHandler
|
from zerver.tornado.handlers import AsyncDjangoHandler
|
||||||
from zerver.tornado.socket import get_sockjs_router
|
from zerver.tornado.socket import get_sockjs_router
|
||||||
|
from zerver.lib.queue import get_queue_client
|
||||||
|
|
||||||
import tornado.web
|
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():
|
def create_tornado_application():
|
||||||
# type: () -> tornado.web.Application
|
# type: () -> tornado.web.Application
|
||||||
urls = (r"/notify_tornado",
|
urls = (r"/notify_tornado",
|
||||||
|
|||||||
Reference in New Issue
Block a user