(s: any)
| 35 | |
| 36 | const execFileAsync = promisify(execFile); |
| 37 | |
| 38 | const timeout = 60000; // 超时 |
| 39 | const PYTHON_PATH = "python3"; // Python 路径,可修改为 venv 中的路径,如:"/path/to/venv/bin/python" |
| 40 | |
| 41 | const QUOTE_RPC_TIMEOUT_MS = 20000; |
| 42 | |
| 43 | function withTimeout<T>(promise: Promise<T>, ms: number, label: string): Promise<T> { |
| 44 | let timer: NodeJS.Timeout; |
| 45 | const timeout = new Promise<never>((_, reject) => { |
| 46 | timer = setTimeout(() => reject(new Error(`${label} timed out after ${ms}ms`)), ms); |
| 47 | if (timer.unref) timer.unref(); |
| 48 | }); |
| 49 | return Promise.race([promise, timeout]).finally(() => clearTimeout(timer)); |
| 50 | } |
no outgoing calls
no test coverage detected