From bc7dfc3dc7ba1c3733645c1ee6328cf96e314370 Mon Sep 17 00:00:00 2001 From: xinwen Date: Thu, 10 Feb 2022 14:40:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=8C=E5=96=84=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E9=98=9F=E5=88=97=20redis=20=E8=BF=9E=E6=8E=A5=E6=9C=AA?= =?UTF-8?q?=E5=85=B3=E9=97=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/notifications/ws.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/notifications/ws.py b/apps/notifications/ws.py index cb2bef8b8..239a0a5bc 100644 --- a/apps/notifications/ws.py +++ b/apps/notifications/ws.py @@ -4,7 +4,6 @@ import json from channels.generic.websocket import JsonWebsocketConsumer from common.utils import get_logger -from .models import SiteMessage from .site_msg import SiteMessageUtil from .signals_handler import new_site_msg_chan @@ -14,6 +13,7 @@ logger = get_logger(__name__) class SiteMsgWebsocket(JsonWebsocketConsumer): disconnected = False refresh_every_seconds = 10 + subscribe = None def connect(self): user = self.scope["user"] @@ -68,5 +68,6 @@ class SiteMsgWebsocket(JsonWebsocketConsumer): def disconnect(self, close_code): self.disconnected = True - self.subscribe.close() self.close() + if self.subscribe: + self.subscribe.close()