From 5207a2bf180af80686c7d6e71923d2d0e3d58b9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E9=92=B0?= Date: Wed, 8 Jul 2026 14:00:38 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20Polymarket=20SSH=E4=BB=A3=E7=90=86?= =?UTF-8?q?=E5=A2=9E=E5=BC=BA=E9=94=99=E8=AF=AF=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 捕获subprocess超时 - 检查空响应 - 捕获JSON解析错误 - 更清晰的错误信息 --- tradingagents/dataflows/polymarket.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tradingagents/dataflows/polymarket.py b/tradingagents/dataflows/polymarket.py index 97637cf..147ba95 100644 --- a/tradingagents/dataflows/polymarket.py +++ b/tradingagents/dataflows/polymarket.py @@ -52,10 +52,18 @@ def _request(path: str, params: dict) -> dict: "-p", str(port), f"root@{host}", f'curl -s "{full_url}"' ] - result = subprocess.run(cmd, capture_output=True, text=True, timeout=REQUEST_TIMEOUT) + try: + result = subprocess.run(cmd, capture_output=True, text=True, timeout=REQUEST_TIMEOUT) + except subprocess.TimeoutExpired: + raise requests.RequestException("SSH proxy timed out") if result.returncode != 0: raise requests.RequestException(f"SSH proxy failed: {result.stderr}") - return json.loads(result.stdout) + if not result.stdout or not result.stdout.strip(): + raise requests.RequestException("SSH proxy returned empty response") + try: + return json.loads(result.stdout) + except json.JSONDecodeError as e: + raise requests.RequestException(f"SSH proxy returned invalid JSON: {e}") def _parse_json_list(value) -> list: