From aca1673ee3fdfe1c71d9f9d99ad7975aa8ea3064 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Mon, 4 Sep 2023 20:40:17 +0800 Subject: [PATCH] fix db session --- app/command.py | 4 ---- app/core/plugin.py | 2 -- app/db/__init__.py | 4 ---- app/plugins/__init__.py | 10 ---------- app/scheduler.py | 4 ---- 5 files changed, 24 deletions(-) diff --git a/app/command.py b/app/command.py index 3de0d7e8..35c258e3 100644 --- a/app/command.py +++ b/app/command.py @@ -242,7 +242,3 @@ class Command(metaclass=Singleton): args = " ".join(event_str.split()[1:]) if self.get(cmd): self.execute(cmd, args, event_channel, event_user) - - def __del__(self): - if self._db: - self._db.close() diff --git a/app/core/plugin.py b/app/core/plugin.py index a719acdf..80e84099 100644 --- a/app/core/plugin.py +++ b/app/core/plugin.py @@ -81,8 +81,6 @@ class PluginManager(metaclass=Singleton): """ # 停止所有插件 for plugin in self._running_plugins.values(): - # 关闭数据库 - plugin.close() # 关闭插件 if hasattr(plugin, "stop_service"): plugin.stop_service() diff --git a/app/db/__init__.py b/app/db/__init__.py index d90df159..acae147d 100644 --- a/app/db/__init__.py +++ b/app/db/__init__.py @@ -41,7 +41,3 @@ class DbOper: self._db = db else: self._db = ScopedSession() - - def __del__(self): - if self._db: - self._db.close() diff --git a/app/plugins/__init__.py b/app/plugins/__init__.py index d602aa27..6e6aeb54 100644 --- a/app/plugins/__init__.py +++ b/app/plugins/__init__.py @@ -183,13 +183,3 @@ 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() - - def __del__(self): - self.close() diff --git a/app/scheduler.py b/app/scheduler.py index aaee8294..a0587669 100644 --- a/app/scheduler.py +++ b/app/scheduler.py @@ -106,7 +106,3 @@ class Scheduler(metaclass=Singleton): """ if self._scheduler.running: self._scheduler.shutdown() - - def __del__(self): - if self._db: - self._db.close()