From 79600e25f1788dc3d017bde2ce3f1020282d39c6 Mon Sep 17 00:00:00 2001 From: ibuler Date: Thu, 18 Nov 2021 16:05:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E8=BF=9E=E6=8E=A5=E6=B2=A1=E6=9C=89=E5=85=B3=E9=97=AD?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/notifications/ws.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/notifications/ws.py b/apps/notifications/ws.py index 4b9d9e4bd..038424e8e 100644 --- a/apps/notifications/ws.py +++ b/apps/notifications/ws.py @@ -2,6 +2,7 @@ import threading import json from redis.exceptions import ConnectionError from channels.generic.websocket import JsonWebsocketConsumer +from django.db import close_old_connections from common.utils import get_logger from .site_msg import SiteMessageUtil @@ -65,8 +66,11 @@ class SiteMsgWebsocket(JsonWebsocketConsumer): logger.debug('Decode json error: ', e) except ConnectionError: logger.debug('Redis chan closed') + finally: + close_old_connections() def disconnect(self, close_code): if self.chan is not None: self.chan.close() self.close() + close_old_connections()