mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-09-04 17:01:09 +00:00
fix: 修复数据库连接没有关闭问题 (#7227)
* fix: 修复数据库连接没有关闭的bug perf: websocket 断开也添加关闭数据库连接 * fix: 修复数据库连接没有关闭问题 Co-authored-by: ibuler <ibuler@qq.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from common.utils import get_logger
|
||||
from django.db import connections
|
||||
|
||||
logger = get_logger(__file__)
|
||||
|
||||
@@ -38,3 +39,8 @@ def get_objects(model, pks):
|
||||
not_found_pks = pks - exists_pks
|
||||
logger.error(f'DoesNotExist: <{model.__name__}: {not_found_pks}>')
|
||||
return objs
|
||||
|
||||
|
||||
def close_old_connections():
|
||||
for conn in connections.all():
|
||||
conn.close_if_unusable_or_obsolete()
|
||||
|
Reference in New Issue
Block a user