fix: bug
This commit is contained in:
@@ -313,8 +313,10 @@ def fetch_news() -> None:
|
||||
if GDELT_DISABLED:
|
||||
_rss_to_gdelt_fallback()
|
||||
_notify_node()
|
||||
if n_fetched > 0:
|
||||
print(f"[{datetime.now().strftime('%H:%M:%S')}] RSS 抓取 {n_fetched} 条,去重后新增 {n_news} 条资讯,面板 {n_panel} 条")
|
||||
ts = datetime.now().strftime("%H:%M:%S")
|
||||
print(f"[{ts}] RSS 抓取 {n_fetched} 条,去重后新增 {n_news} 条资讯,写入事件脉络 {n_panel} 条")
|
||||
if n_fetched == 0:
|
||||
print(f"[{ts}] (0 条:检查网络、RSS 源或 KEYWORDS 过滤)")
|
||||
except Exception as e:
|
||||
LAST_FETCH["error"] = str(e)
|
||||
print(f"[{datetime.now().strftime('%H:%M:%S')}] 新闻抓取失败: {e}")
|
||||
@@ -433,10 +435,8 @@ def _get_conflict_stats() -> dict:
|
||||
|
||||
@app.on_event("startup")
|
||||
async def startup():
|
||||
"""仅启动后台定时任务,不阻塞首次抓取,避免启动超时(验证脚本 /crawler/status 可尽快就绪)"""
|
||||
global _bg_task
|
||||
loop = asyncio.get_event_loop()
|
||||
await loop.run_in_executor(None, fetch_news)
|
||||
await loop.run_in_executor(None, fetch_gdelt_events)
|
||||
_bg_task = asyncio.create_task(_periodic_fetch())
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user