fix: 修复数据库连接没有关闭问题 (#7227)

* fix: 修复数据库连接没有关闭的bug

perf: websocket 断开也添加关闭数据库连接

* fix: 修复数据库连接没有关闭问题

Co-authored-by: ibuler <ibuler@qq.com>
This commit is contained in:
fit2bot
2021-11-18 18:47:01 +08:00
committed by GitHub
parent 6e5dcc738e
commit d2df8acd84
9 changed files with 87 additions and 35 deletions

View File

@@ -24,9 +24,9 @@ from copy import deepcopy
from common.const import LDAP_AD_ACCOUNT_DISABLE
from common.utils import timeit, get_logger
from common.db.utils import close_old_connections
from users.utils import construct_user_email
from users.models import User
from orgs.models import Organization
from authentication.backends.ldap import LDAPAuthorizationBackend, LDAPUser
logger = get_logger(__file__)
@@ -331,15 +331,17 @@ class LDAPSyncUtil(object):
def perform_sync(self):
logger.info('Start perform sync ldap users from server to cache')
self.pre_sync()
try:
self.pre_sync()
self.sync()
self.post_sync()
except Exception as e:
error_msg = str(e)
logger.error(error_msg)
self.set_task_error_msg(error_msg)
self.post_sync()
logger.info('End perform sync ldap users from server to cache')
finally:
logger.info('End perform sync ldap users from server to cache')
close_old_connections()
class LDAPImportUtil(object):