fix: Polymarket SSH代理增强错误处理

- 捕获subprocess超时
- 检查空响应
- 捕获JSON解析错误
- 更清晰的错误信息
This commit is contained in:
小钰 committed 2026-07-08 14:00:38 +08:00
1 parent 6bba181307
commit 5207a2bf18
1 file changed
+10 -2
+10 -2
View File
@@ -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: