fix db session
This commit is contained in:
@ -242,7 +242,3 @@ class Command(metaclass=Singleton):
|
|||||||
args = " ".join(event_str.split()[1:])
|
args = " ".join(event_str.split()[1:])
|
||||||
if self.get(cmd):
|
if self.get(cmd):
|
||||||
self.execute(cmd, args, event_channel, event_user)
|
self.execute(cmd, args, event_channel, event_user)
|
||||||
|
|
||||||
def __del__(self):
|
|
||||||
if self._db:
|
|
||||||
self._db.close()
|
|
||||||
|
@ -81,8 +81,6 @@ class PluginManager(metaclass=Singleton):
|
|||||||
"""
|
"""
|
||||||
# 停止所有插件
|
# 停止所有插件
|
||||||
for plugin in self._running_plugins.values():
|
for plugin in self._running_plugins.values():
|
||||||
# 关闭数据库
|
|
||||||
plugin.close()
|
|
||||||
# 关闭插件
|
# 关闭插件
|
||||||
if hasattr(plugin, "stop_service"):
|
if hasattr(plugin, "stop_service"):
|
||||||
plugin.stop_service()
|
plugin.stop_service()
|
||||||
|
@ -41,7 +41,3 @@ class DbOper:
|
|||||||
self._db = db
|
self._db = db
|
||||||
else:
|
else:
|
||||||
self._db = ScopedSession()
|
self._db = ScopedSession()
|
||||||
|
|
||||||
def __del__(self):
|
|
||||||
if self._db:
|
|
||||||
self._db.close()
|
|
||||||
|
@ -183,13 +183,3 @@ class _PluginBase(metaclass=ABCMeta):
|
|||||||
channel=channel, mtype=mtype, title=title, text=text,
|
channel=channel, mtype=mtype, title=title, text=text,
|
||||||
image=image, link=link, userid=userid
|
image=image, link=link, userid=userid
|
||||||
))
|
))
|
||||||
|
|
||||||
def close(self):
|
|
||||||
"""
|
|
||||||
关闭数据库连接
|
|
||||||
"""
|
|
||||||
if self.db:
|
|
||||||
self.db.close()
|
|
||||||
|
|
||||||
def __del__(self):
|
|
||||||
self.close()
|
|
||||||
|
@ -106,7 +106,3 @@ class Scheduler(metaclass=Singleton):
|
|||||||
"""
|
"""
|
||||||
if self._scheduler.running:
|
if self._scheduler.running:
|
||||||
self._scheduler.shutdown()
|
self._scheduler.shutdown()
|
||||||
|
|
||||||
def __del__(self):
|
|
||||||
if self._db:
|
|
||||||
self._db.close()
|
|
||||||
|
Reference in New Issue
Block a user