feat: SSH连接池串行化 + Polymarket/数据源统一走连接池

- 新增ssh_proxy_pool.py: 全局单例连接池,队列串行化SSH请求
- stockstats_utils.py: _fetch_via_ssh改用连接池
- polymarket.py: 跳过本地直接走SSH连接池
- 消除并发SSH资源竞争问题
This commit is contained in:
小钰 committed 2026-07-08 14:34:41 +08:00
1 parent 5207a2bf18
commit 709ea0fd78
3 files changed
+131 -45

No files matched your search

+3 -13
View File
@@ -43,19 +43,9 @@ def _get_ssh_config():
def _fetch_via_ssh(url: str, timeout: int = 30) -> str:
"""Fetch a URL through the foreign server via SSH tunnel."""
host, port, password = _get_ssh_config()
cmd = [
"sshpass", "-p", password,
"ssh", "-o", "StrictHostKeyChecking=no",
"-o", "ConnectTimeout=15",
"-p", str(port), f"root@{host}",
f'curl -s "{url}" -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"'
]
result = subprocess.run(cmd, capture_output=True, text=True, timeout=timeout)
if result.returncode != 0:
raise RuntimeError(f"SSH fetch failed: {result.stderr}")
return result.stdout
"""Fetch a URL through the foreign server via SSH tunnel (uses connection pool)."""
from .ssh_proxy_pool import ssh_proxy_fetch
return ssh_proxy_fetch(url, timeout)
def _yf_download_via_proxy(symbol: str, start: str, end: str) -> pd.DataFrame: