From a87942c8f6dff6ff412e3c5b88372c0b97a718fd Mon Sep 17 00:00:00 2001 From: jxxghp Date: Wed, 2 Aug 2023 10:10:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BB=E5=8A=A8gc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/chain/message.py | 4 ++++ app/chain/subscribe.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/app/chain/message.py b/app/chain/message.py index c413895b..553a851b 100644 --- a/app/chain/message.py +++ b/app/chain/message.py @@ -1,3 +1,4 @@ +import gc from typing import Any from app.chain.download import * @@ -315,6 +316,9 @@ 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 6dc7543d..e79a5af2 100644 --- a/app/chain/subscribe.py +++ b/app/chain/subscribe.py @@ -1,5 +1,6 @@ import json import re +import gc from datetime import datetime from typing import Dict, List, Optional, Union, Tuple @@ -415,6 +416,9 @@ 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]]): """