mirror of
https://github.com/jumpserver/jumpserver.git
synced 2026-01-29 21:51:31 +00:00
fix: 修复数据库连接没有关闭问题 (#7227)
* fix: 修复数据库连接没有关闭的bug perf: websocket 断开也添加关闭数据库连接 * fix: 修复数据库连接没有关闭问题 Co-authored-by: ibuler <ibuler@qq.com>
This commit is contained in:
@@ -137,9 +137,14 @@ def check_server_performance_period():
|
||||
|
||||
@shared_task(queue="ansible")
|
||||
def hello(name, callback=None):
|
||||
from users.models import User
|
||||
import time
|
||||
time.sleep(10)
|
||||
|
||||
count = User.objects.count()
|
||||
print("Hello {}".format(name))
|
||||
print("Count: ", count)
|
||||
time.sleep(1)
|
||||
return count
|
||||
|
||||
|
||||
@shared_task
|
||||
|
||||
@@ -2,12 +2,12 @@ import time
|
||||
import os
|
||||
import threading
|
||||
import json
|
||||
from channels.generic.websocket import JsonWebsocketConsumer
|
||||
|
||||
from common.utils import get_logger
|
||||
|
||||
from common.db.utils import close_old_connections
|
||||
from .celery.utils import get_celery_task_log_path
|
||||
from .ansible.utils import get_ansible_task_log_path
|
||||
from channels.generic.websocket import JsonWebsocketConsumer
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
@@ -86,3 +86,4 @@ class TaskLogWebsocket(JsonWebsocketConsumer):
|
||||
def disconnect(self, close_code):
|
||||
self.disconnected = True
|
||||
self.close()
|
||||
close_old_connections()
|
||||
|
||||
Reference in New Issue
Block a user