From 9944474ba028946770953dc566254d97c17ce63a Mon Sep 17 00:00:00 2001 From: xinwen Date: Tue, 13 Apr 2021 18:33:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20settings=20=E8=AE=A2=E9=98=85=E4=B8=8D?= =?UTF-8?q?=E7=A8=B3=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/settings/signals_handler.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/settings/signals_handler.py b/apps/settings/signals_handler.py index ef649f732..6264fb9e6 100644 --- a/apps/settings/signals_handler.py +++ b/apps/settings/signals_handler.py @@ -6,6 +6,7 @@ import threading from django.dispatch import receiver from django.db.models.signals import post_save, pre_save from django.utils.functional import LazyObject +from django.db import close_old_connections from jumpserver.utils import current_request from common.decorator import on_transaction_commit @@ -75,6 +76,7 @@ def subscribe_settings_change(sender, **kwargs): try: sub = setting_pub_sub.subscribe() for msg in sub.listen(): + close_old_connections() if msg["type"] != "message": continue item = msg['data'].decode() @@ -82,6 +84,7 @@ def subscribe_settings_change(sender, **kwargs): Setting.refresh_item(item) except Exception as e: logger.exception(f'subscribe_settings_change: {e}') + close_old_connections() Setting.refresh_all_settings() t = threading.Thread(target=keep_subscribe)