From adc8d9592e10d92ec3dfeff93d9b90beeaecd0e6 Mon Sep 17 00:00:00 2001 From: Chuan-Zheng Lee Date: Sat, 4 Dec 2021 17:45:28 +1300 Subject: [PATCH] Bump channels to 3.0.4 Involves consequential compatibility changes: https://channels.readthedocs.io/en/stable/releases/3.0.0.html --- config/requirements_core.txt | 2 +- tabbycat/routing.py | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/config/requirements_core.txt b/config/requirements_core.txt index 1cece700fd6..27cd11327e9 100644 --- a/config/requirements_core.txt +++ b/config/requirements_core.txt @@ -28,7 +28,7 @@ psycopg2==2.9.2 # For Django to talk to postgres # Channels asgiref==3.3.4 # Must set version to avoid Channels bug #1713 -channels==2.4.0 # Channels; also includes the Daphne server +channels==3.0.4 # Channels; also includes the Daphne server channels_redis==3.2.0 # Channels Layer # Misc diff --git a/tabbycat/routing.py b/tabbycat/routing.py index fb9c013af07..62e07713949 100644 --- a/tabbycat/routing.py +++ b/tabbycat/routing.py @@ -1,6 +1,7 @@ from channels.auth import AuthMiddlewareStack from channels.routing import ChannelNameRouter, ProtocolTypeRouter, URLRouter from django.conf.urls import url +from django.core.asgi import get_asgi_application from actionlog.consumers import ActionLogEntryConsumer from adjallocation.consumers import AdjudicatorAllocationWorkerConsumer, PanelEditConsumer @@ -17,28 +18,29 @@ application = ProtocolTypeRouter({ - # HTTP handled automatically + # HTTP handler + "http": get_asgi_application(), # WebSocket handlers "websocket": AuthMiddlewareStack( URLRouter([ # TournamentOverviewContainer - url(r'^ws/(?P[-\w_]+)/action_logs/$', ActionLogEntryConsumer), - url(r'^ws/(?P[-\w_]+)/ballot_results/$', BallotResultConsumer), - url(r'^ws/(?P[-\w_]+)/ballot_statuses/$', BallotStatusConsumer), + url(r'^ws/(?P[-\w_]+)/action_logs/$', ActionLogEntryConsumer.as_asgi()), + url(r'^ws/(?P[-\w_]+)/ballot_results/$', BallotResultConsumer.as_asgi()), + url(r'^ws/(?P[-\w_]+)/ballot_statuses/$', BallotStatusConsumer.as_asgi()), # CheckInStatusContainer - url(r'^ws/(?P[-\w_]+)/checkins/$', CheckInEventConsumer), + url(r'^ws/(?P[-\w_]+)/checkins/$', CheckInEventConsumer.as_asgi()), # Draw and Preformed Panel Edits - url(r'^ws/(?P[-\w_]+)/round/(?P[-\w_]+)/debates/$', DebateEditConsumer), - url(r'^ws/(?P[-\w_]+)/round/(?P[-\w_]+)/panels/$', PanelEditConsumer), + url(r'^ws/(?P[-\w_]+)/round/(?P[-\w_]+)/debates/$', DebateEditConsumer.as_asgi()), + url(r'^ws/(?P[-\w_]+)/round/(?P[-\w_]+)/panels/$', PanelEditConsumer.as_asgi()), ]), ), # Worker handlers (which don't need a URL/protocol) "channel": ChannelNameRouter({ # Name used in runworker cmd : SyncConsumer responsible - "notifications": NotificationQueueConsumer, # Email sending - "adjallocation": AdjudicatorAllocationWorkerConsumer, - "venues": VenuesWorkerConsumer, + "notifications": NotificationQueueConsumer.as_asgi(), # Email sending + "adjallocation": AdjudicatorAllocationWorkerConsumer.as_asgi(), + "venues": VenuesWorkerConsumer.as_asgi(), }), })