feat: fpw plugins, validation/crawl perf, WS stats, test DB isolation
- Add Free_Proxy_Website-style fpw_* plugins and register them - Per-plugin crawl timeout (crawl_timeout_seconds=120); remove global crawl_timeout setting - Validator: fix connect vs total timeout on save; SOCKS session LRU cache; drop redundant semaphore - Validation handler uses single DB connection; batch upsert after crawl; WorkerPool put_nowait - Remove unused max_retries from settings API/UI; settings maintenance SQL + init_db cleanup of deprecated keys - WebSocket dashboard stats; ProxyList pool_filter and API alignment - POST /api/proxies/delete-one for IPv6-safe deletes; task poll stops on 404 - pytest uses PROXYPOOL_DB_PATH=db/proxies.test.sqlite so tests do not wipe production DB - .gitignore: explicit proxies.test.sqlite patterns; fix plugin_service ValidationException import Made-with: Cursor
This commit is contained in:
25
app/api/realtime.py
Normal file
25
app/api/realtime.py
Normal file
@@ -0,0 +1,25 @@
|
||||
"""实时统计广播后台任务"""
|
||||
import asyncio
|
||||
|
||||
from fastapi import FastAPI
|
||||
|
||||
from app.core.config import settings
|
||||
from app.core.log import logger
|
||||
from app.services.dashboard_stats import get_dashboard_stats
|
||||
|
||||
|
||||
async def stats_broadcaster_loop(app: FastAPI) -> None:
|
||||
manager = app.state.ws_manager
|
||||
interval = settings.ws_stats_interval_seconds
|
||||
while True:
|
||||
try:
|
||||
await asyncio.sleep(interval)
|
||||
if manager.connection_count == 0:
|
||||
continue
|
||||
scheduler = app.state.scheduler
|
||||
stats = await get_dashboard_stats(scheduler.running)
|
||||
await manager.broadcast_json({"type": "stats", "data": stats})
|
||||
except asyncio.CancelledError:
|
||||
break
|
||||
except Exception:
|
||||
logger.exception("stats broadcaster tick failed")
|
||||
Reference in New Issue
Block a user