perf(http): 并行获取数据加速数据加载
使用 ThreadPoolExecutor 并行获取多个标的的数据: - 信号源 (index): 11个标的并行获取 - 交易源 (ETF): 4个标的并行获取 - 溢价率数据: 4个标的并行获取 性能提升:5个标的从 ~15s 串行 → ~4.6s 并行(约 3x 加速) 修改: - 增大 urllib3 连接池 maxsize=16 支持并行连接 - 使用 concurrent.futures.ThreadPoolExecutor
This commit is contained in:
@@ -24,7 +24,10 @@ load_dotenv()
|
||||
# HTTP client (urllib3 替代 requests,修复 SSL EOF 问题)
|
||||
# ============================================================
|
||||
|
||||
_http_pool = urllib3.PoolManager()
|
||||
_http_pool = urllib3.PoolManager(
|
||||
maxsize=16, # 支持并行连接
|
||||
timeout=urllib3.Timeout(connect=10, read=120)
|
||||
)
|
||||
|
||||
def _http_get(url: str, params: dict = None, timeout: int = 120) -> urllib3.HTTPResponse:
|
||||
"""使用 urllib3 发起 GET 请求(替代 requests.get,修复 OpenSSL 3.5 + Caddy 的 SSL EOF 问题)"""
|
||||
|
||||
Reference in New Issue
Block a user