From 0914dace420d72a6f7e0f31430d6d10d245a7d41 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Tue, 1 Aug 2023 20:25:34 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E5=8F=96=E6=B6=88Chain=E5=85=A8=E5=B1=80?= =?UTF-8?q?=E5=8D=95=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/chain/__init__.py | 4 ++-- app/chain/message.py | 8 +++----- app/chain/subscribe.py | 4 ---- 3 files changed, 5 insertions(+), 11 deletions(-) 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]]): """