mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-08 08:57:09 +08:00
remove gc
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
from typing import Callable, Any, Optional
|
||||
import gc
|
||||
|
||||
from playwright.sync_api import sync_playwright, Page
|
||||
from cf_clearance import sync_cf_retry, sync_stealth
|
||||
from playwright.sync_api import sync_playwright, Page
|
||||
|
||||
from app.log import logger
|
||||
|
||||
|
||||
@@ -67,8 +67,6 @@ class PlaywrightHelper:
|
||||
context.close()
|
||||
if browser:
|
||||
browser.close()
|
||||
# 强制垃圾回收
|
||||
gc.collect()
|
||||
except Exception as e:
|
||||
logger.error(f"Playwright初始化失败: {str(e)}")
|
||||
|
||||
@@ -120,8 +118,6 @@ class PlaywrightHelper:
|
||||
context.close()
|
||||
if browser:
|
||||
browser.close()
|
||||
# 强制垃圾回收
|
||||
gc.collect()
|
||||
except Exception as e:
|
||||
logger.error(f"Playwright初始化失败: {str(e)}")
|
||||
|
||||
|
||||
+5
-9
@@ -1,4 +1,3 @@
|
||||
import gc
|
||||
import re
|
||||
import traceback
|
||||
from typing import List, Tuple, Union, Optional
|
||||
@@ -228,7 +227,8 @@ class RssHelper:
|
||||
},
|
||||
}
|
||||
|
||||
def parse(self, url, proxy: bool = False, timeout: Optional[int] = 15, headers: dict = None) -> Union[List[dict], None, bool]:
|
||||
def parse(self, url, proxy: bool = False,
|
||||
timeout: Optional[int] = 15, headers: dict = None) -> Union[List[dict], None, bool]:
|
||||
"""
|
||||
解析RSS订阅URL,获取RSS中的种子信息
|
||||
:param url: RSS地址
|
||||
@@ -320,12 +320,8 @@ class RssHelper:
|
||||
if len(items) > self.MAX_RSS_ITEMS:
|
||||
logger.warning(f"RSS条目过多: {len(items)},仅处理前{self.MAX_RSS_ITEMS}个")
|
||||
|
||||
for i, item in enumerate(items[:items_count]):
|
||||
for item in items[:items_count]:
|
||||
try:
|
||||
# 定期执行垃圾回收
|
||||
if i > 0 and i % 100 == 0:
|
||||
gc.collect()
|
||||
|
||||
# 使用xpath提取信息,更高效
|
||||
title_nodes = item.xpath('.//title')
|
||||
title = title_nodes[0].text if title_nodes and title_nodes[0].text else ""
|
||||
@@ -339,7 +335,8 @@ class RssHelper:
|
||||
# 种子页面
|
||||
link_nodes = item.xpath('.//link')
|
||||
if link_nodes:
|
||||
link = link_nodes[0].text if hasattr(link_nodes[0], 'text') and link_nodes[0].text else link_nodes[0].get('href', '')
|
||||
link = link_nodes[0].text if hasattr(link_nodes[0], 'text') and link_nodes[0].text else \
|
||||
link_nodes[0].get('href', '')
|
||||
else:
|
||||
link = ""
|
||||
|
||||
@@ -403,7 +400,6 @@ class RssHelper:
|
||||
del root
|
||||
if ret_xml is not None:
|
||||
del ret_xml
|
||||
gc.collect()
|
||||
|
||||
return ret_array
|
||||
|
||||
|
||||
Reference in New Issue
Block a user