diff --git a/app/chain/__init__.py b/app/chain/__init__.py index bcc28686..766d3006 100644 --- a/app/chain/__init__.py +++ b/app/chain/__init__.py @@ -16,10 +16,10 @@ from app.schemas import TransferInfo, TransferTorrent, ExistMediaInfo, Downloadi WebhookEventInfo from app.schemas.types import TorrentStatus, MediaType, MediaImageType from app.utils.object import ObjectUtils -from app.utils.singleton import AbstractSingleton, Singleton +from app.utils.singleton import AbstractSingleton -class ChainBase(AbstractSingleton, metaclass=Singleton): +class ChainBase(AbstractSingleton): """ 处理链基类 """ diff --git a/app/chain/message.py b/app/chain/message.py index 827389a2..816821f9 100644 --- a/app/chain/message.py +++ b/app/chain/message.py @@ -1,5 +1,5 @@ from typing import Any -import gc + from app.chain.download import * from app.chain.media import MediaChain from app.chain.search import SearchChain @@ -9,9 +9,10 @@ from app.core.event import EventManager from app.log import logger from app.schemas import Notification from app.schemas.types import EventType, MessageChannel +from app.utils.singleton import Singleton -class MessageChain(ChainBase): +class MessageChain(ChainBase, metaclass=Singleton): """ 外来消息处理链 """ @@ -312,9 +313,6 @@ class MessageChain(ChainBase): userid=userid, total=len(medias)) # 保存缓存 self.save_cache(user_cache, self._cache_file) - # 主动回收内存 - del user_cache - gc.collect() def __post_medias_message(self, channel: MessageChannel, title: str, items: list, userid: str, total: int): diff --git a/app/chain/subscribe.py b/app/chain/subscribe.py index 4d28ecc7..6dc7543d 100644 --- a/app/chain/subscribe.py +++ b/app/chain/subscribe.py @@ -1,6 +1,5 @@ import json import re -import gc from datetime import datetime from typing import Dict, List, Optional, Union, Tuple @@ -416,9 +415,6 @@ class SubscribeChain(ChainBase): self.__match(torrents_cache) # 保存缓存到本地 self.save_cache(torrents_cache, self._cache_file) - # 主动回收内存 - del torrents_cache - gc.collect() def __match(self, torrents_cache: Dict[str, List[Context]]): """