fix
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
import gc
|
||||
import pickle
|
||||
import traceback
|
||||
from abc import ABCMeta
|
||||
@ -55,6 +56,10 @@ class ChainBase(metaclass=ABCMeta):
|
||||
pickle.dump(cache, f)
|
||||
except Exception as err:
|
||||
logger.error(f"保存缓存 {filename} 出错:{err}")
|
||||
finally:
|
||||
# 主动资源回收
|
||||
del cache
|
||||
gc.collect()
|
||||
|
||||
def run_module(self, method: str, *args, **kwargs) -> Any:
|
||||
"""
|
||||
|
@ -1,4 +1,3 @@
|
||||
import gc
|
||||
from typing import Any
|
||||
|
||||
from app.chain.download import *
|
||||
@ -316,9 +315,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):
|
||||
@ -339,6 +335,5 @@ class MessageChain(ChainBase):
|
||||
self.post_torrents_message(Notification(
|
||||
channel=channel,
|
||||
title=f"【{title}】共找到{total}条相关资源,请回复对应数字下载(0: 自动选择 p: 上一页 n: 下一页)",
|
||||
items=items,
|
||||
userid=userid
|
||||
), torrents=items)
|
||||
|
@ -1,6 +1,5 @@
|
||||
import json
|
||||
import re
|
||||
import gc
|
||||
from datetime import datetime
|
||||
from typing import Dict, List, Optional, Union, Tuple
|
||||
|
||||
@ -399,15 +398,14 @@ class SubscribeChain(ChainBase):
|
||||
# 如果超过了200条则移除最早的一条
|
||||
if len(torrents_cache[domain]) > settings.CACHE_CONF.get('torrents'):
|
||||
torrents_cache[domain].pop(0)
|
||||
# 回收资源
|
||||
del torrents
|
||||
else:
|
||||
logger.info(f'{indexer.get("name")} 获取到种子')
|
||||
# 从缓存中匹配订阅
|
||||
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]]):
|
||||
"""
|
||||
|
Reference in New Issue
Block a user