fix 取消Chain全局单例
This commit is contained in:
@ -16,10 +16,10 @@ from app.schemas import TransferInfo, TransferTorrent, ExistMediaInfo, Downloadi
|
|||||||
WebhookEventInfo
|
WebhookEventInfo
|
||||||
from app.schemas.types import TorrentStatus, MediaType, MediaImageType
|
from app.schemas.types import TorrentStatus, MediaType, MediaImageType
|
||||||
from app.utils.object import ObjectUtils
|
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):
|
||||||
"""
|
"""
|
||||||
处理链基类
|
处理链基类
|
||||||
"""
|
"""
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from typing import Any
|
from typing import Any
|
||||||
import gc
|
|
||||||
from app.chain.download import *
|
from app.chain.download import *
|
||||||
from app.chain.media import MediaChain
|
from app.chain.media import MediaChain
|
||||||
from app.chain.search import SearchChain
|
from app.chain.search import SearchChain
|
||||||
@ -9,9 +9,10 @@ from app.core.event import EventManager
|
|||||||
from app.log import logger
|
from app.log import logger
|
||||||
from app.schemas import Notification
|
from app.schemas import Notification
|
||||||
from app.schemas.types import EventType, MessageChannel
|
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))
|
userid=userid, total=len(medias))
|
||||||
# 保存缓存
|
# 保存缓存
|
||||||
self.save_cache(user_cache, self._cache_file)
|
self.save_cache(user_cache, self._cache_file)
|
||||||
# 主动回收内存
|
|
||||||
del user_cache
|
|
||||||
gc.collect()
|
|
||||||
|
|
||||||
def __post_medias_message(self, channel: MessageChannel,
|
def __post_medias_message(self, channel: MessageChannel,
|
||||||
title: str, items: list, userid: str, total: int):
|
title: str, items: list, userid: str, total: int):
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
import gc
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import Dict, List, Optional, Union, Tuple
|
from typing import Dict, List, Optional, Union, Tuple
|
||||||
|
|
||||||
@ -416,9 +415,6 @@ class SubscribeChain(ChainBase):
|
|||||||
self.__match(torrents_cache)
|
self.__match(torrents_cache)
|
||||||
# 保存缓存到本地
|
# 保存缓存到本地
|
||||||
self.save_cache(torrents_cache, self._cache_file)
|
self.save_cache(torrents_cache, self._cache_file)
|
||||||
# 主动回收内存
|
|
||||||
del torrents_cache
|
|
||||||
gc.collect()
|
|
||||||
|
|
||||||
def __match(self, torrents_cache: Dict[str, List[Context]]):
|
def __match(self, torrents_cache: Dict[str, List[Context]]):
|
||||||
"""
|
"""
|
||||||
|
Reference in New Issue
Block a user