mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-08 17:08:35 +08:00
fix:memory use
This commit is contained in:
@@ -199,11 +199,11 @@ class TorrentsChain(ChainBase, metaclass=Singleton):
|
|||||||
# 取前N条
|
# 取前N条
|
||||||
torrents = torrents[:settings.CACHE_CONF["refresh"]]
|
torrents = torrents[:settings.CACHE_CONF["refresh"]]
|
||||||
if torrents:
|
if torrents:
|
||||||
# 过滤出没有处理过的种子
|
# 过滤出没有处理过的种子 - 优化:使用集合查找,避免重复创建字符串列表
|
||||||
|
cached_signatures = {f'{t.torrent_info.title}{t.torrent_info.description}'
|
||||||
|
for t in torrents_cache.get(domain) or []}
|
||||||
torrents = [torrent for torrent in torrents
|
torrents = [torrent for torrent in torrents
|
||||||
if f'{torrent.title}{torrent.description}'
|
if f'{torrent.title}{torrent.description}' not in cached_signatures]
|
||||||
not in [f'{t.torrent_info.title}{t.torrent_info.description}'
|
|
||||||
for t in torrents_cache.get(domain) or []]]
|
|
||||||
if torrents:
|
if torrents:
|
||||||
logger.info(f'{indexer.get("name")} 有 {len(torrents)} 个新种子')
|
logger.info(f'{indexer.get("name")} 有 {len(torrents)} 个新种子')
|
||||||
else:
|
else:
|
||||||
@@ -246,8 +246,8 @@ class TorrentsChain(ChainBase, metaclass=Singleton):
|
|||||||
# 优化:清理不再需要的临时变量
|
# 优化:清理不再需要的临时变量
|
||||||
del meta, mediainfo, context
|
del meta, mediainfo, context
|
||||||
# 回收资源
|
# 回收资源
|
||||||
|
torrents.clear()
|
||||||
del torrents
|
del torrents
|
||||||
# 定期执行垃圾回收
|
|
||||||
gc.collect()
|
gc.collect()
|
||||||
else:
|
else:
|
||||||
logger.info(f'{indexer.get("name")} 没有获取到种子')
|
logger.info(f'{indexer.get("name")} 没有获取到种子')
|
||||||
|
|||||||
Reference in New Issue
Block a user