fix db session
This commit is contained in:
parent
a7a0889867
commit
9b17d55ac0
@ -181,6 +181,8 @@ class Command(metaclass=Singleton):
|
||||
"""
|
||||
self._event.set()
|
||||
self._thread.join()
|
||||
if self._db:
|
||||
self._db.close()
|
||||
|
||||
def get_commands(self):
|
||||
"""
|
||||
|
@ -83,6 +83,9 @@ class PluginManager(metaclass=Singleton):
|
||||
"""
|
||||
# 停止所有插件
|
||||
for plugin in self._running_plugins.values():
|
||||
# 关闭数据库
|
||||
if hasattr(plugin, "close"):
|
||||
plugin.close()
|
||||
# 关闭插件
|
||||
if hasattr(plugin, "stop_service"):
|
||||
plugin.stop_service()
|
||||
|
@ -56,3 +56,7 @@ class SystemConfigOper(DbOper, metaclass=Singleton):
|
||||
if not key:
|
||||
return self.__SYSTEMCONF
|
||||
return self.__SYSTEMCONF.get(key)
|
||||
|
||||
def __del__(self):
|
||||
if self._db:
|
||||
self._db.close()
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -184,3 +184,10 @@ class _PluginBase(metaclass=ABCMeta):
|
||||
channel=channel, mtype=mtype, title=title, text=text,
|
||||
image=image, link=link, userid=userid
|
||||
))
|
||||
|
||||
def close(self):
|
||||
"""
|
||||
关闭数据库连接
|
||||
"""
|
||||
if self.db:
|
||||
self.db.close()
|
||||
|
@ -106,3 +106,5 @@ class Scheduler(metaclass=Singleton):
|
||||
"""
|
||||
if self._scheduler.running:
|
||||
self._scheduler.shutdown()
|
||||
if self._db:
|
||||
self._db.close()
|
||||
|
Loading…
x
Reference in New Issue
Block a user