mirror of https://github.com/jumpserver/jumpserver
fix: settings 订阅不稳定
parent
ce6b9de07c
commit
9944474ba0
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue